Repository navigation
test(jobs): prove two replicas never run an exclusive job at once, and a cancelled holder hands over - #307
Merged
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 17 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
PiquelChips
force-pushed
the
test/job-runner-exclusivity
branch
from
November 2, 2026 14:40
48bee9c to
6976006
Compare
… over on cancel Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PiquelChips
force-pushed
the
test/job-runner-exclusivity
branch
from
November 2, 2026 15:22
6976006 to
e299f0a
Compare
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.
#33 asked for a test that two job runners never overlap on the same exclusive job, and that cancelling the holder mid-run frees the lock. So far, exclusivity was only tested on the lock itself and on a single runner whose run panics. Nothing ran two
Jobsrunners side by side, as two replicas do.This adds that test. Two real
Jobsrunners share one test database and run a test-only exclusive job. The job checks every 20 ms and holds the lock for 100 ms per run. It logs when each run starts and whether it finished or was cancelled. The cancelled entry is logged before the run's connection closes, so before the lock can be taken.After a few runs, the test drops whichever runner is mid-run. It then expects that run to be logged as cancelled and the other runner to start. At the end, it checks that the log is all start/end pairs that never overlap.
The only production change is a test-only
LockKey::ExclusivityTest, behind thetest-supportfeature. Database tests share one database and run in parallel, so this test can't shareLockKey::Testwith the panic test.Proof:
just db testpasses all 309 tests, and the new test passed 20 runs in a row (about 0.45 s each). I broke the code two ways and the new test failed both times:try_exclusivehand out a lock that is already held;Reviewed with review-loop: 2 rounds with 2× GPT-6.1 Sol and Claude Opus 5.5. Verdict: approved
Note
Written by Claude Opus 5.5 in Claude Code and reviewed by GPT-6.1 Sol and Claude Opus 5.5 (via T3 Code)
🤖 Generated with Claude Code