Skip to content

Can't query tables after restart, log parsing error #216

@csuwildcat

Description

@csuwildcat

Which version are you using?
version 2.3.7

Describe the bug
When using a freshly created DB, everything seems to work, but as soon as I kill node with Ctrl + C and restart the server, all queries for fetching data from tables results in the following error:

C:\repos\identity-hub\packages\implementation\node_modules\snap-db\bin\database.js:699

    throw new Error("Error parsing log file!");
    ^

Error: Error parsing log file!
    at processLog_1 (C:\repos\identity-hub\packages\implementation\node_modules\snap-db\bin\database.js:699:31)
    at ReadStream.<anonymous> (C:\repos\identity-hub\packages\implementation\node_modules\snap-db\bin\database.js:755:21)

Expected behavior
Queries against established tables with data that previously was present and queriable should remain so.

Example
I can get a copy of the repo up soon, but here are the relevant code sections:
export default class Storage {

export default class Storage {

  constructor(did, options = {}){
    this.did = did;
    this.dbName = did.split(':').slice(0, 3).join('-');
    this.ready = nano().createDatabase({
      id: this.dbName,
      mode: 'PERM',
      tables: this.tables = [
        {
          name: 'stack',
          model: {
            "id:string": { pk: true, immutable: true },
            "file:string": { immutable: true }
          }
        },
        {
          name: 'profile',
          model: {
            "id:string": { pk: true, immutable: true },
            "data:object": {},
            "signature:object": {}
          }
        },
        {
          name: 'permissions',
          model: {
            "id:string": { pk: true, immutable: true },
            "schema:string": { immutable: true, notNull: true },
            "data:object": { immutable: true },
            "signature:object": {}
          },
          indexes: {
            "schema:string": { ignore_case: true }
          }
        },
        {
          name: 'collections',
          model: {
            "id:string": { pk: true, immutable: true },
            "type:string": { immutable: true },
            "nonce:string": { immutable: true },
            "schema:string": { immutable: true, notNull: true },
            "root:string": { immutable: true },
            "parent:string": { immutable: true },
            "tags:array": {},
            "data:object": { immutable: true },
            "signature:object": {}
          },
          indexes: {
            "schema:string": { ignore_case: true }
          }
        },
        {
          name: 'actions',
          model: {
            "id:string": { pk: true, immutable: true },
            "nonce:string": { immutable: true },
            "schema:string": { immutable: true, notNull: true },
            "root:string": { immutable: true },
            "parent:string": { immutable: true },
            "data:object": { immutable: true },
            "signature:object": { immutable: true }
          },
          indexes: {
            "schema:string": {ignore_case: true}
          }
        }
      ]
    })  
  }

  async txn(fn){
    return this.ready.then(async () => {
      await nano().useDatabase(this.dbName);
      return fn(nano);
    });
  }

}

ClassInstance.txn(db => db('collections').query('select').exec()).catch(e => console.log(e));

//  ^ this call fails

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions