Repository navigation
test(crewmate-prune): release the lock holder on the second expired wait - #30818
Conversation
First Principles Review (Opus 5.5) — ⏭️ skippedRevision |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: this only changes a test. The holder now lets go on the second expired wait, read from the "crewmate prune still waiting" warning, instead of on a wall-clock timer. Notes
[DESIGN-REVIEWED] f5877f7 Description read[DESCRIPTION-READ] aedcca983e48f5832688c03ef0d175db7718ea2216173b4050290ea557d68a84 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
test_a_holder_that_outlasts_the_wait_is_waited_for_not_given_up_on released the holder on a 0.45 s timer and asserted at least two expired 0.1 s waits. On a loaded runner the time before the first wait began used up most of that window, so only one wait expired. Release from inside the wait loop instead, when the second "still waiting" WARNING is logged, so the count no longer depends on the wall clock. Fixes #23363 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2175a17 to
f5877f7
Compare
Original PR: #23389
Problem / Motivation
Goal:
test_a_holder_that_outlasts_the_wait_is_waited_for_not_given_up_onpasses or fails on what the prune lock wait does, not on how fast the CI runner is.The test failed on Windows shard 7/8 of #23334 with
assert 1 >= 2(#23363). It held the prune lock in a thread, released it onthreading.Timer(0.45, release.set)and assertedreport.lock_waits >= 2withPRUNE_LOCK_WAIT_S = 0.1. That counts expired waits against wall-clock time: on a loaded runner the time before the first wait begins can use up most of the 0.45 s, so only one wait expires.Why it matters
The test guards the rule that a contending prune pass never gives up while another process holds the lock, which keeps a session from binding a crewmate the holder has not judged yet. A red it produces on unrelated PRs costs a rerun each time, and it teaches people to ignore that test.
Not a goal
crewmate_prune_migration.pyorPRUNE_LOCK_WAIT_S.What changed (motivation → approach → change)
assert report.lock_waits >= 2sees 1 on a loaded Windows runner.mig.logger.warningand counts thecrewmate prune still waitingWARNING, which the loop logs once per expired wait, right afterreport.lock_waits += 1. On the second one it setsrelease, so the holder lets go only after two waits have expired, whatever the runner speed. Thethreading.Timeris gone. The test also asserts the holder thread finished. Every other assertion is unchanged.Backwards compatibility
Compatible: test-only change. No production code is touched.
Removes nothing: the test keeps every assertion it had.
Tests
Proof: not provable -- test-only change
releasewould then never be set, the contender would return withlock_waits == 1, andassert report.lock_waits >= 2would fail. So the test still checks the no-give-up rule, and the count it asserts now follows from the release condition instead of from timing.test_crewmate_prune_migration.pyplustest_flake_pattern_ratchet.py: 149 passed, 2 skipped, 1 failed. The failure isTestKeptOnDoubt::test_a_link_at_a_thread_path_is_no_record, withOSError: [WinError 1314]: this host may not create symlinks. That test is untouched. black, isort, flake8 and the comment-history gate are clean.Manual verification
N/A — unit coverage sufficient: this is a test-only change, and the test runs the real lock-contention path.
Related Issues
Fixes #23363
Sibling sweep
Swept: git grep -n "threading.Timer(" -- test/test_crewmate_prune_migration.py
Sibling: test/test_crewmate_prune_migration.py:1573 -- not affected -- keeps the default 120 s wait and asserts lock_waits == 0, so its 0.2 s Timer only ends the hold and counts nothing against the clock
Pattern harvest
Not generalizable: the shape "count expirations of a short timeout inside a fixed wall-clock window" is already a named flake class in testing-conventions.md, and this was one instance of it.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
🤖 Generated with Claude Code