docs: explain SQLite concurrency caveats + DSN tuning (RUK-137) - #22
Merged
Conversation
The original ticket asked for runtime WAL verification, but auditing the code showed nothing actually depends on WAL being on — the "In WAL mode the transaction provides row-level locking" comment in sqlite/get_for_processing.go is a vestigial note, not a real dependency. Adding code to enable+check WAL would have been ceremonial. What is real and worth telling users: - SQLite serializes writes at the file level. Multiple goque workers calling CureTasks / GetTasksForProcessing in parallel hit SQLITE_BUSY immediately because dbtx.WithinTx uses BEGIN DEFERRED: the SELECT takes a SHARED lock, the UPDATE can't upgrade to RESERVED, and _busy_timeout does NOT apply to lock upgrades. The fix is to start tx as BEGIN IMMEDIATE via the _txlock=immediate DSN parameter — surfaced in README as a copy-pasteable snippet. - Single-binary constraint: even with the DSN tuning, two processes pointing at the same .sqlite.db file will deadlock. If you need real concurrency, the message stays the same: PG or MySQL. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The original ticket asked for runtime WAL verification, but auditing
the code showed nothing actually depends on WAL being on — the
"In WAL mode the transaction provides row-level locking" comment in
sqlite/get_for_processing.go is a vestigial note, not a real
dependency. Adding code to enable+check WAL would have been
ceremonial.
What is real and worth telling users:
SQLite serializes writes at the file level. Multiple goque workers
calling CureTasks / GetTasksForProcessing in parallel hit
SQLITE_BUSY immediately because dbtx.WithinTx uses BEGIN DEFERRED:
the SELECT takes a SHARED lock, the UPDATE can't upgrade to
RESERVED, and _busy_timeout does NOT apply to lock upgrades. The
fix is to start tx as BEGIN IMMEDIATE via the _txlock=immediate
DSN parameter — surfaced in README as a copy-pasteable snippet.
Single-binary constraint: even with the DSN tuning, two processes
pointing at the same .sqlite.db file will deadlock.
If you need real concurrency, the message stays the same: PG or
MySQL.
Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com