Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
csuwildcat opened this issue Aug 25, 2021 · 1 comment
Open

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

csuwildcat opened this issue Aug 25, 2021 · 1 comment

Comments

@csuwildcat
Copy link

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
@csuwildcat
Copy link
Author

Interestingly, when I remove the indexes the DB seems to function normally. I don't understand why that is, perhaps I am using the indexes feature incorrectly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant