Repository navigation
fix(sqlite): retain attachment identity pins until workers close - #4736
Closed
ScriptedAlchemy wants to merge 2 commits into
Closed
ScriptedAlchemy wants to merge 2 commits into
ScriptedAlchemy wants to merge 2 commits into
Conversation
|
Owner
Author
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.
Root cause
Refs #4513. Even after the other pathname-identity and verified-foreign-reader fixes,
RepositoryPhysicalAttachmentFactorystill dropped the original raw SQLite file pin after starting workers for existing read-write and read-only attachments. For newly created stores,commit_initializationdropped its pin while those SQLite connections were still alive. On Unix, closing any raw descriptor for the same inode can discard unrelated process-wide SQLite POSIX locks, risking corruption under concurrent access.Fix
Keep the attachment's original verified descriptor in its physical owner until the SQLite readers and writer have shut down. For an initialized store, transfer the pending-initialization pin to retained ownership on commit; preserve
abort_initialization's exact created-file cleanup authority. Release retained pins only after normal drain/close or after both lost-file worker groups have exited. Keep the retained pin last in state drop order so it cannot close ahead of worker owner destruction. No storage format, WAL policy, admission, authorization, or integrity control changes.Regression
A Linux attachment regression exercises real SQLite-backed writable, read-only and newly initialized stores, requires a live retained descriptor throughout reads/initialization commit, and verifies it releases after worker shutdown. Existing lost-file, WAL, replacement and shutdown tests remain unchanged and cover their existing lifecycle boundaries.
Verification and scope
Reviewed the
attach_opened,attach_read_only,commit_initialization, lost-file and shutdown paths on the currentmaster, and confirmed PR #4720 and PR #4732 change different files. The patch is one Rust source file with a focused regression and no whitespace errors. Rust/Bazel compilation and test execution have not run in this automation environment; CI must executebazel test //crates/tracedecay-rusqlite-runtime:unit_test --test_output=errorson this exact head, plus the broader macOS concurrency matrix before merge. This is source-level evidence of a further lock-lifetime hazard, not proof that the reported live external-sqlite3corruption scenario is fully resolved. Keep #4513 open until integrated macOS/Unix stress and integrity verification. The separate PR-repair automation owns CI follow-up and merges.