fix: shorten write transaction lifetimes to resolve sync lock contention#7
Merged
Merged
Conversation
The watcher pipeline held write transactions open across async yields and idle periods, preventing WAL checkpointing and causing periodic sync to fail with "database is locked" on every cycle. - Flush after each event in processDue() so no transaction spans an await boundary - Flush after on_checkpoint writes so no transaction lingers for up to 60s - Flush at start of syncOnce() to commit any pending pipeline work before sync reads/writes (intentional cross-subsystem commit)
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.
Summary
database is lockedon every cycleprocessDue(), afteron_checkpointwrites, and at the start ofsyncOnce()so no transaction is ever held across an async boundaryTest plan
bun test— 95 tests passwildcard launchd restart+wildcard status— initial sync succeeds, pending: nonetail -30 ~/.wildcard/launchd.err.logshows no newdatabase is lockederrorssqlite3 ~/.wildcard/timeline.db "SELECT key, value FROM state WHERE key LIKE 'sync%'"— cursors advancing,last_errorempty