Repository navigation
fork-kit/heavy: the queue tests' own look waits for the lock in real time (#551) - #560
Merged
Merged
Conversation
…time (#551) The tests that race real caller processes read the live tickets through the test's fake-clock queue. Its lock wait (30 s in 0.05 s steps) passes on the fake clock without any real time going by, so whenever a caller held the queue lock for a few real milliseconds (deciding, writing its ticket) the test's look raised LockBusy at once. heavy_queue.py is fine: a SIGKILLed process never keeps the flock, and heavy's own verbs wait on the real clock. live() now takes the lock through a queue on the real clock. Two new tests: a real process that holds the lock for 0.3 s (fails on the old code with the same LockBusy as in CI), and a lock holder killed with -9 leaves the lock free at once for the next look and a rerun. Fixes #551 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scuttletoby
added a commit
that referenced
this pull request
Nov 21, 2026
#569: the CI failure tested a merge onto a base from before #560. There, the test's live() look ran on the fake clock, so its 30 s lock wait passed in no real time. #560 already moved live() to the real clock. Reproduced: 3 of 50 runs failed on the old base with 8 CPU hogs, 0 of 50 on this branch. The lock release after SIGKILL is the kernel's flock drop, and tests on main cover it. #744: - signal_in signals only through a pidfd; no fallback to kill(pid) - docker-label notes go to ~/.local/state/heavy/labelled when the /run/user note cannot reach heavy; heavy passes the folders it reads as HEAVY_MARKS - the refusal under a shell after leaving heavy's scope names the cause - tests: done() waits for the guard; the install test leaves no note; every read and wait of a test process has a timeout, checked by an AST test - README: cgroup.kill reaches sudo/setuid processes; who refuses to start; the --value exit code Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
scuttletoby
added a commit
that referenced
this pull request
Nov 21, 2026
…time (#551) (#560) The tests that race real caller processes read the live tickets through the test's fake-clock queue. Its lock wait (30 s in 0.05 s steps) passes on the fake clock without any real time going by, so whenever a caller held the queue lock for a few real milliseconds (deciding, writing its ticket) the test's look raised LockBusy at once. heavy_queue.py is fine: a SIGKILLed process never keeps the flock, and heavy's own verbs wait on the real clock. live() now takes the lock through a queue on the real clock. Two new tests: a real process that holds the lock for 0.3 s (fails on the old code with the same LockBusy as in CI), and a lock holder killed with -9 leaves the lock free at once for the next look and a rerun. Fixes #551 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
scuttletoby
added a commit
that referenced
this pull request
Nov 21, 2026
#569: the CI failure tested a merge onto a base from before #560. There, the test's live() look ran on the fake clock, so its 30 s lock wait passed in no real time. #560 already moved live() to the real clock. Reproduced: 3 of 50 runs failed on the old base with 8 CPU hogs, 0 of 50 on this branch. The lock release after SIGKILL is the kernel's flock drop, and tests on main cover it. #744: - signal_in signals only through a pidfd; no fallback to kill(pid) - docker-label notes go to ~/.local/state/heavy/labelled when the /run/user note cannot reach heavy; heavy passes the folders it reads as HEAVY_MARKS - the refusal under a shell after leaving heavy's scope names the cause - tests: done() waits for the guard; the install test leaves no note; every read and wait of a test process has a timeout, checked by an AST test - README: cgroup.kill reaches sudo/setuid processes; who refuses to start; the --value exit code Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
scuttletoby
added a commit
that referenced
this pull request
Nov 21, 2026
…time (#551) (#560) The tests that race real caller processes read the live tickets through the test's fake-clock queue. Its lock wait (30 s in 0.05 s steps) passes on the fake clock without any real time going by, so whenever a caller held the queue lock for a few real milliseconds (deciding, writing its ticket) the test's look raised LockBusy at once. heavy_queue.py is fine: a SIGKILLed process never keeps the flock, and heavy's own verbs wait on the real clock. live() now takes the lock through a queue on the real clock. Two new tests: a real process that holds the lock for 0.3 s (fails on the old code with the same LockBusy as in CI), and a lock holder killed with -9 leaves the lock free at once for the next look and a rerun. Fixes #551 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
scuttletoby
added a commit
that referenced
this pull request
Nov 21, 2026
#569: the CI failure tested a merge onto a base from before #560. There, the test's live() look ran on the fake clock, so its 30 s lock wait passed in no real time. #560 already moved live() to the real clock. Reproduced: 3 of 50 runs failed on the old base with 8 CPU hogs, 0 of 50 on this branch. The lock release after SIGKILL is the kernel's flock drop, and tests on main cover it. #744: - signal_in signals only through a pidfd; no fallback to kill(pid) - docker-label notes go to ~/.local/state/heavy/labelled when the /run/user note cannot reach heavy; heavy passes the folders it reads as HEAVY_MARKS - the refusal under a shell after leaving heavy's scope names the cause - tests: done() waits for the guard; the install test leaves no note; every read and wait of a test process has a timeout, checked by an AST test - README: cgroup.kill reaches sudo/setuid processes; who refuses to start; the --value exit code Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
scuttletoby
added a commit
that referenced
this pull request
Nov 21, 2026
#569: the CI failure tested a merge onto a base from before #560. There, the test's live() look ran on the fake clock, so its 30 s lock wait passed in no real time. #560 already moved live() to the real clock. Reproduced: 3 of 50 runs failed on the old base with 8 CPU hogs, 0 of 50 on this branch. The lock release after SIGKILL is the kernel's flock drop, and tests on main cover it. #744: - signal_in signals only through a pidfd; no fallback to kill(pid) - docker-label notes go to ~/.local/state/heavy/labelled when the /run/user note cannot reach heavy; heavy passes the folders it reads as HEAVY_MARKS - the refusal under a shell after leaving heavy's scope names the cause - tests: done() waits for the guard; the install test leaves no note; every read and wait of a test process has a timeout, checked by an AST test - README: cgroup.kill reaches sudo/setuid processes; who refuses to start; the --value exit code Co-authored-by: Claude Opus 5.5 <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.
Fixes #551
Root cause
QueueTests.live()read the tickets throughself.q, the test's queue on a fake clock.take()retries the lock everyLOCK_RETRY(0.05 s) untillock_wait()(30 s) — but on the fake clock eachpause()only advances the fake time, so the whole 30 s wait goes by in about a millisecond of real time. The tests that race real caller processes (test_a_waiter_killed_with_9_frees_its_place,test_two_callers_at_the_same_instant) polllive()while the caller takes the lock every 0.2 s to look and write its ticket. Whenever the test's look landed while the caller held the lock for a few real milliseconds (more likely on a loaded CI runner), it raisedLockBusyat once.heavy_queue.pyitself is fine: a SIGKILLed process never keeps the flock (the kernel drops it with the process), and heavy's own verbs and peaks wait on the real clock. No retry or longer sleep was added.Fix
live()takes the lock through a queue on the real clock (same box and settings), so it waits for a real holder in real time. Everything else in the tests stays on the fake clock.Tests
test_a_look_waits_in_real_time_for_a_process_holding_the_lock: forced interleaving. A real process takes the queue lock and lets go 0.3 s later, and the test's look must wait for it. On the old code it fails with the sameLockBusy ... stayed takentraceback as in CI (I ran it). With the fix it passes.test_a_lock_holder_killed_with_9_frees_the_lock_at_once: the state question for the lock (stopped half-way). A process killed with -9 while it holds the lock leaves it free at once: a non-blocking flock succeeds, the next look works, and a rerun is admitted on its first look.test_a_rerun_starts_clean_and_keeps_order), empty state after a reboot (test_after_a_reboot_the_folders_are_made_again), old or garbled tickets.python3 -I -B fork-kit/heavy/tests/queue.test.py: 70 tests OK. The four lock-racing tests passed 5 runs in a row.General vs project
General: test-only change in the fork kit's
heavyqueue tests. Nothing project-specific; no project config is involved.🤖 Generated with Claude Code