-
Notifications
You must be signed in to change notification settings - Fork 59
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
Database is locked error in kypher #657
Comments
I got this error too. I tried to run a simpler query while a more complex and time consuming one is running in the background. (base) root@vm096:/app/kgtk/temp# kgtk query -i $GRAPH_CLAIMS --match '(item)-[:P1340]->(value1), (item)-[:P1340]->(value2)' --where 'value1 < value2' --return 'item, value1, value2' --limit 50 > prop_P1340.txt & (base) root@vm096:/app/kgtk/temp# ps -ef | grep kgtk root 54525 54423 0 23:38 pts/1 00:00:00 grep --color=auto kgtk |
I got this error just trying to check database cache while a query was runing (base) root@vm096:/app/kgtk/temp# kgtk query --show-cache |
The SQLite3 database uses a rollback journal by default which uses an exclusive lock when the database is written. That prevents any concurrent reading activity, thus the error when you try to read something from the DB if another query currently imports data in the background or tries to create an index or any other update activity. --show-cache also needs to read the database and fails for similar reasons. See here for some background on DB locking: https://www.sqlite.org/lockingv3.html There is a disclaimer in the query manual against the use of query pipes for these reasons, but it might not be clear that that also applies to other scenarios where the DB gets written. I am not quite sure why the pipe at the beginning of this thread fails, but some of the generic KGTK commands also use or try to read the DB, which would explain why it fails with the same error. There is a write-ahead-logging (or WAL) journal mode that I could enable by default. It does allow concurrent readers (but only one writer) which would fix the problem. I've played with that in the past. There are some advantages and disadvantages (see here: https://www.sqlite.org/wal.html). Let me look into that again to see if it's safe to change to that. |
I pushed a fix to dev that changes the default journal mode to WAL which allows one writer and multiple parallel readers which should solve the various problems above. Unfortunately, that does slow down import of large data files significantly, so I added a new --single-user mode option that switches back to the old journal mode and behavior to get the faster import times for those files if needed (see manual). It's ok to switch back and forth between the two modes without causing problems for the DB. In the process I also upgraded query pipelines which are working nicely now, before they were very limited. |
Describe the bug
Running this command,
throws an error,
Running this command second time works, this is in a cell in a notebook, I dont know what triggers this error. But it seems to be happening consistently.
Creating this issue to debug in future
The text was updated successfully, but these errors were encountered: