-
Notifications
You must be signed in to change notification settings - Fork 574
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
Adding bookmarks concurrently doesn't work #739
Comments
WAL doesn't seem to solve the problem even with shared cache enabled. I tried A solution can be to throttle the queries on application level and block execution if the database is locked... but would it be an appropriate solution? |
Would a busy timeout on the connection help? |
I tried it, the only difference was that it took 5 sec (with timeout 5000) to throw these errors. I played with shared cache, tx lock, sync, mutex, etc., actually all parameters that make sense and couldn't bring it to a stable state. Somebody may be luckier with the parameters but I don't think that it'd work with sqlite (which is not designed to be written by concurrent processes btw). Btw here are all tweakable options for the driver: https://github.com/mattn/go-sqlite3#connection-string |
@rutkai Did that include manually creating a mutex? For example:
|
Hey @yonas, the problem cannot be fixed within the application this way. The problem is that each subprocess will have its own memory segment with different mutexes in it, and we're not talking about just threads within the same process. One dirty solution could be to use a lock file, but that's rather dirty, and imo this issue is supposed to be solved on the sqlite driver level (which is appearantly not). But is this a usecase btw? I mean, if we need to make bookmark adding sequential, then why not executing the cli command one-by-one? For bigger volumes, using a real db behind shiori is also a viable solution. This is a constraint that may be worth documenting, but apart from that, I think that's all. |
This is not going to work with SQLite in some way or another, the real solution here for that driver is executing the command one at a time or use the API to add the bookmarks, which should take care of the concurrency though it still may happen with sqlite. |
FWIW I could reproduce the issue with sequential (i.e. not concurrent) requests to the API. Just calls to The error shows up after about a dozen bookmarks added. |
Ok, I'm voting for using a lock file for now, and if/when the sqlite driver can handle atomic transactions.
As @lenormf mentioned, we're currently not able to use neither the CLI nor |
Yeah, that's why I mention that it may still happen since even if the command has finished running the OS may be still syncing the changes to the FS. Unsure if we can set up a parameter in sqlite to block calls until the file has been commited and synced to disk. |
This issue has been automatically marked as stale because it has not had any activity for quite some time. |
Data
Describe the bug / actual behavior
Adding bookmarks concurrently doesn't work.
Expected behavior
There should be a mutex / lock that allows the first client to write to the database, while the remaining wait / block.
To Reproduce
Notes
SQLite WAL
The text was updated successfully, but these errors were encountered: