Skip to content

SQLITE_CONSTRAINT: UNIQUE constraint failed: global_cache. cacheKey, global_cache. dir, global_cache. branch, global_cache. artifactId] #1840

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

Closed
3 tasks done
Patrick-Erichsen opened this issue Jul 26, 2024 · 11 comments
Labels
area:indexing Relates to embedding and indexing ide:jetbrains Relates specifically to JetBrains extension ide:vscode Relates specifically to VS Code extension kind:bug Indicates an unexpected problem or unintended behavior

Comments

@Patrick-Erichsen
Copy link
Collaborator

Patrick-Erichsen commented Jul 26, 2024

Before submitting your bug report

Relevant environment info

- OS: 
- Continue: 0.0.56 JetBrains, recent VS Code pre-releases (e.g. 0.9.188)
- IDE:
- Model:
- config.json:

Description

Some users are receiving the error in the title while indexing after upgrading from previous version of Continue.

The unique constraint was introduced here: https://github.com/continuedev/continue/pull/1795/files#diff-b1fd84889028918892926feb0f8dd8c5f5b574119374d8efd474fb9438430b6aR47-R76

User reports

https://discord.com/channels/1108621136150929458/1156679146932535376/1266320982809903186

To reproduce

Not exactly sure when/how users are experiencing this. I need to pinpoint which versions for VS Code/JetBrains this change was introduced.

The issue arises when attempting to insert new rows into the DB while indexing, e.g. on load, adding docs, etc.

Log output

Core process exited with output: .................continue\out\config. js 1.1kb .................continue\out\config. js. map 266b  Done in 4ms node:internal/ process/ promises:288 triggerUncaughtException(err, true /* fromPromise */); ^  [Error: SQLITE_CONSTRAINT: UNIQUE constraint failed: global_cache. cacheKey, global_cache. dir, global_cache. branch, global_cache. artifactId] { errno: 19, code: 'SQLITE_CONSTRAINT' }  Node. js v18.5.0
@dosubot dosubot bot added area:indexing Relates to embedding and indexing ide:jetbrains Relates specifically to JetBrains extension ide:vscode Relates specifically to VS Code extension kind:bug Indicates an unexpected problem or unintended behavior labels Jul 26, 2024
@Patrick-Erichsen
Copy link
Collaborator Author

Patrick-Erichsen commented Jul 26, 2024

Hey @joshvera, curious if you ran into this error at all?

@sestinj and I ran into it a few times locally when switching between branches but I had assumed that for the regular user flow the deduplication logic you had here would prevent unique constraint errors.

We haven't had any user reports from VS Code of this issue yet, so I'm wondering if for some reason that code path isn't being invoked in JetBrains.

@joshvera
Copy link
Contributor

joshvera commented Jul 26, 2024

I didn't. I'd be surprised if the codepath isn't triggering, otherwise I assume the tables wouldn't exist to begin with.

The easiest solution would be to turn INSERT INTO global_cache into a REPLACE OR INSERT INTO global_cache, but it appears there's an old tag in global cache, and application logic calling the GlobalCacheCodeBaseIndex.update method is giving it a tag to add before removing.

The issue could also be the following:

await Promise.all([
  ...remove.map(({ cacheKey }) => {
    return this.deleteOrRemoveTag(cacheKey, tag);
  }),
  ...add.map(({ cacheKey }) => {
    return this.computeOrAddTag(cacheKey, tag);
  }),
]);

Which resolves adds and removes concurrently. If we add before we remove, then we'd see this issue. I'd check here first.

AFK today, so I can't look into it but I can take a look tomorrow if it's not too pressing. I'd try removing Promise.all first and serializing those calls.

@levdad
Copy link

levdad commented Jul 29, 2024

I have this error as well.
It happens when using both VS Code and Rider (in my case).
The indexing will crash and sometimes will even break Rider.
The workaround I found is to delete the cache and reopen only one IDE.

@Patrick-Erichsen
Copy link
Collaborator Author

Thanks for the writeup @joshvera - I'm leaning towards just making the REPLACE OR INSERT INTO global_cache change. The concurrent add/remove logic feels like it could be the culprit but even if it is, I think the upsert is a good solution to avoid anything similar in the future.

@levdad , I will circle back here once we get this pushed to pre-release. Please let me know if you continue to have issues once you upgrade.

@JulianGerhard21
Copy link

Hi,

I am also experiencing this issue leading to an unusable plugin.

Is there a way to use the merged solution in Webstorm/JetBrains in general or do I have to wait for a new release? If so, when should I expect the latter?

Kind regards
Julian

@songcee
Copy link

songcee commented Jul 30, 2024 via email

@levdad
Copy link

levdad commented Jul 30, 2024

@Patrick-Erichsen do we need to update both plugins to prerelease?
Could you let us know which versions to install?

@sskorol
Copy link

sskorol commented Aug 3, 2024

JB plugin is still broken.
Screenshot from 2024-08-03 14-17-47

@sskorol
Copy link

sskorol commented Aug 3, 2024

Nevermind, it's easier to build it from sources... FIY, the issue is fixed in the dev branch.

@JulianGerhard21
Copy link

@Patrick-Erichsen - will there be a new version of the plugin for the JetBrains Suite at all?

@songcee
Copy link

songcee commented Aug 23, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:indexing Relates to embedding and indexing ide:jetbrains Relates specifically to JetBrains extension ide:vscode Relates specifically to VS Code extension kind:bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

6 participants