mirror of
https://github.com/go-shiori/shiori.git
synced 2026-04-25 06:25:54 +03:00
[GH-ISSUE #739] Adding bookmarks concurrently doesn't work #361
Labels
No labels
component:backend
component:builds
component:builds
component:extension
component:frontend
component:readability
database
database:mysql
database:postgres
database:sqlite
feature:ebooks
github_actions
good first issue
hacktoberfest
note:duplicate?
note:fixed?
note:out-of-scope?
os:windows
priority:high
priority:low
pull-request
resolution:as-intended
resolution:cant-reproduce
resolution:duplicate
resolution:fixed
resolution:wontfix
tag:TBD
tag:big-task
tag:help-wanted
tag:huge-data
tag:meta
tag:more-info
tag:next
tag:no-stale
tag:requires-migrations
tag:research
tag:security 🛡️
tag:stale
tag:waiting-for-assignee
type:bug
type:documentation
type:enhancement
type:meta
type:ux
user:cli
user:web
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/shiori#361
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @yonas on GitHub (Sep 20, 2023).
Original GitHub issue: https://github.com/go-shiori/shiori/issues/739
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
@rutkai commented on GitHub (Sep 24, 2023):
WAL doesn't seem to solve the problem even with shared cache enabled.
I tried
sqlx.ConnectContext(ctx, "sqlite", databasePath+"?_journal_mode=WAL&cache=shared")but it still shows error messages (though less often).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?
@Mxrk commented on GitHub (Sep 26, 2023):
Would a busy timeout on the connection help?
https://www.sqlite.org/c3ref/busy_timeout.html
@rutkai commented on GitHub (Sep 26, 2023):
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
@yonas commented on GitHub (Jan 26, 2024):
@rutkai Did that include manually creating a mutex? For example:
@rutkai commented on GitHub (Jan 26, 2024):
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.
@fmartingr commented on GitHub (Jan 26, 2024):
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.
@lenormf commented on GitHub (Jan 27, 2024):
FWIW I could reproduce the issue with sequential (i.e. not concurrent) requests to the API.
Just calls to
curl, one after the other, without any delays between.The error shows up after about a dozen bookmarks added.
@yonas commented on GitHub (Jan 28, 2024):
@rutkai
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
curlone after the other with no delays between calls.@fmartingr commented on GitHub (Feb 4, 2024):
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.
@stale[bot] commented on GitHub (Mar 6, 2024):
This issue has been automatically marked as stale because it has not had any activity for quite some time.
It will be closed if no further activity occurs.
Thank you for your contributions.