test(queue): the concurrency item #117 left open on issue 103 - #123
Merged
Conversation
The last unticked box: "Compaction is safe against a concurrent append (test with the sync lock held)." It is safe BECAUSE of the lock, not on its own, so a test that only asserted the happy path would be claiming a property the code does not have. Both halves are demonstrated instead. First, the hazard is real and shown to be real: patching writeFileSync to append to the queue in the window between the temp write and the rename, the appended row IS lost. It was on the old inode and went with it. If that test ever starts failing because the append survives, compaction grew a merge step and the lock requirement should be re-examined — a finding, not a broken test. Second, the lock genuinely excludes a second holder, and releases. Without that "compaction runs inside the lock" would guarantee nothing. Third, the positive case in the arrangement sync actually uses — lock, compact, release — with a would-be concurrent writer refused mid-operation. Fourth, a source fact pinning the ORDER in sync.js. Reordering those lines would leave the other three green while reopening the window, which is exactly the kind of regression the other three cannot see. ci:local exit 0: 956 root tests, 302 dashboard.
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
The last unticked box on #103: "Compaction is safe against a concurrent append (test with the sync lock held)." #117 shipped the feature and named this as the honest gap.
It is safe because of the lock, not on its own. A test that only asserted the happy path would be claiming a property the code does not have, so both halves are demonstrated.
Four tests
1. The hazard is real, and shown to be real. Patching
writeFileSyncto append to the queue in the window between the temp write and the rename, the appended row is lost — it was on the old inode and went with it.If that test ever starts failing because the append survives, compaction grew a merge step and the lock requirement should be re-examined. That is a finding, not a broken test, and the test says so.
2. The lock genuinely excludes a second holder, and releases. Without that, "compaction runs inside the lock" would guarantee nothing.
3. The positive case in the arrangement
syncactually uses — lock, compact, release — with a would-be concurrent writer refused mid-operation.4. A source fact pinning the order in
sync.js. Reordering those lines would leave the other three green while reopening the window, which is exactly the regression the other three cannot see.Test plan
ci:localexit 0 — 956 root tests (+4), 302 dashboardAfter this
#103's definition of done is complete, with two deviations already recorded on the issue: automatic compaction is deliberately not shipped (it rewrote an 11 MB production queue during
npm test), and thedoctorcheck is awarnrather than afailbecause the rows are already on disk and being rendered.