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

SQLite error: database is locked #2931

Open
JoeMShanahan opened this issue May 26, 2022 · 5 comments
Open

SQLite error: database is locked #2931

JoeMShanahan opened this issue May 26, 2022 · 5 comments

Comments

@JoeMShanahan
Copy link

I am using HLS on a large project with VSCode, and I am being spammed with the following the error:

Error condition, please check your setup and/or the issue tracker: 
HieDb writer thread SQLite error:
  SQLite3 returned ErrorBusy while attempting to perform step: database is locked

I've tried restarting HLS and destroying any stack cache (didn't really expect that one to work!). Happy to provide anything else if there's not enough to go on here. I am thinking there's a manual way to clear the lock, but I don't know what that is!

@eddiemundo
Copy link
Collaborator

eddiemundo commented May 27, 2022

You can try removing ~/.cache/ghcide.

@aryairani
Copy link

I run into this problem too. Restarting VSCode fixes it temporarily, but I wonder if there's a better solution?

@eddiemundo
Copy link
Collaborator

eddiemundo commented May 29, 2022

According to https://www.sqlite.org/rescode.html#locked it says if not in shared memory mode then this error only occurs if a "conflict" happens on the same connection. So because shared memory is off (I think), then it must be because of a conflict.

The only operations I see that might do this after HLS has started up is when indexing hie files (addRefsFromLoaded from hiedb), and when setSomethingModified (deleteMissingRealFiles from hiedb) which happens when closing files/workspace config changes. All writes to the hiedb are queued up, but the reads aren't, so my theory is that a read, and a delete on the same table or row is happening simultaneously resulting in a locked error.

Another possibility is writes are happening simultaneously at startup somewhere, but there are only a few places that can happen, writer thread startup, and runWithDb.

So if my theory is actually right then I guess one way of fixing it is to retry not only on SQLITE_BUSY but SQLITE_LOCKED as well.

@July541
Copy link
Collaborator

July541 commented May 29, 2022

hls-call-hierarchy-plugin had a hiedb write before hls-1.7.0.0, but I never saw errors like this while I'm debugging that, just write here for reference.

@PaulJohnson
Copy link

I believe this is the bug being discussed in haskell/vscode-haskell#300 and haskell/vscode-haskell#480

Briefly, it seems the VSCode Haskell extension sometimes starts up more than one HLS. That would explain why you get database lock errors. You will probably see duplicate info on popups driven by HLS as well.

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

No branches or pull requests

6 participants