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

Deleting multiple VCs in a short period of time #656

Closed
atz3n opened this issue Aug 9, 2021 · 2 comments
Closed

Deleting multiple VCs in a short period of time #656

atz3n opened this issue Aug 9, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@atz3n
Copy link

atz3n commented Aug 9, 2021

Bug severity
3

Describe the bug
There is an error that will be thrown by TypeORM when you try to delete multiple VCs in a short period of time.

To Reproduce
Run the following code:

const vcAmount = 1000;

const vcHashes: string[] = [];
for (let i = 0 ; i < vcAmount ; i++) {
    const vc = await agent.createVerifiableCredential({
        credential: {
            issuer: {
                id: "<a stored DID>"
            },
            credentialSubject: {
                id: "did:some:random-did",
                payload: i
            }
        },
        proofFormat: "jwt"
    });
    const hash = await agent.dataStoreSaveVerifiableCredential({ verifiableCredential: vc });
    vcHashes.push(hash);
}

for (let i = 0 ; i < vcHashes.length ; i++) {
    try {
        await agent.dataStoreDeleteVerifiableCredential({ hash: vcHashes[i] });
    } catch (error) {
        console.log("index:", i);
        console.log(error);
        break;
    }
}

Observed behaviour
The following error will be thrown for a random VC:

index: 100
QueryFailedError: SQLITE_CONSTRAINT: FOREIGN KEY constraint failed
    at new QueryFailedError (.../src/error/QueryFailedError.ts:11:9)
    at Statement.handler (.../src/driver/sqlite/SqliteQueryRunner.ts:79:26)
    at Statement.replacement (.../node_modules/sqlite3/lib/trace.js:25:27) {
  errno: 19,
  code: 'SQLITE_CONSTRAINT',
  __augmented: true,
  query: 'DELETE FROM "credential" WHERE "hash" = ?',
  parameters: [
    'e75b34ce33e56cb0cb522b13804ecfd1ea9ad847f7bf078d06414ba6aab0a8de268c5a96dc2934ea4da477ec97d8e9f7732899be8c43b92736b439fef00b7b1a'
  ]
}

Expected behaviour
No error will be thrown and all VCs are deleted.

Additional context
I've also added it into our discussion here.

Versions (please complete the following information):

  • @veramo/data-store: 2.0.2-next.9
  • Node Version: v14.16.1
@atz3n atz3n added the bug Something isn't working label Aug 9, 2021
@mirceanis
Copy link
Member

Can you try with version 2.0.2-next.15 ?
I believe this was fixed in #652

@mirceanis mirceanis self-assigned this Aug 10, 2021
@atz3n
Copy link
Author

atz3n commented Aug 10, 2021

works like a charm 👍

@atz3n atz3n closed this as completed Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants