Skip to content

test(crewmate-prune): release the lock holder on the second expired wait - #30818

Merged
chenmingwei23 merged 1 commit into
mainfrom
greener/pr-23389
Nov 6, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
greener/pr-23389

Conversation

@iamwhatever

Copy link
Copy Markdown
Contributor

CI-runner copy of #23389 by @leonlaiyc, opened for #23450.
The fork PR's test shards hit the 70-minute limit on the fork runners, so this in-repo branch runs CI on the large CodeBuild runners.
The commit and its authorship are kept unchanged. All credit goes to @leonlaiyc.

Original PR: #23389


Problem / Motivation

Goal: test_a_holder_that_outlasts_the_wait_is_waited_for_not_given_up_on passes 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 on threading.Timer(0.45, release.set) and asserted report.lock_waits >= 2 with PRUNE_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

What changed (motivation → approach → change)

  • Symptom: assert report.lock_waits >= 2 sees 1 on a loaded Windows runner.
  • Root cause: the release was timed by a wall clock that starts before the contender's first wait, so the number of expired waits inside the window depended on scheduling.
  • Change: the test now wraps mig.logger.warning and counts the crewmate prune still waiting WARNING, which the loop logs once per expired wait, right after report.lock_waits += 1. On the second one it sets release, so the holder lets go only after two waits have expired, whatever the runner speed. The threading.Timer is 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

  • If the pass gave up after its first expired wait, the WARNING would be logged only once. release would then never be set, the contender would return with lock_waits == 1, and assert report.lock_waits >= 2 would 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.
  • Local (Windows, Python 3.13): the test passed 3 runs in a row. test_crewmate_prune_migration.py plus test_flake_pattern_ratchet.py: 149 passed, 2 skipped, 1 failed. The failure is TestKeptOnDoubt::test_a_link_at_a_thread_path_is_no_record, with OSError: [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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable): N/A, test-only
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

🤖 Generated with Claude Code

@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners November 5, 2026 22:51
@iamwhatever
iamwhatever requested a review from CrysisDeu November 5, 2026 22:51
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ⏭️ skipped

Revision f5877f72ae83eb7b28893e10db430d01506c8c64 ships no reviewable capability (docs, tests or generated files only), so there is nothing to inventory. Does not block merge.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision f5877f72ae83eb7b28893e10db430d01506c8c64 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of f5877f72ae83eb7b28893e10db430d01506c8c64 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] f5877f7

False positive or not applicable? A repository writer can comment:
/ai-review override gpt f5877f72ae83eb7b28893e10db430d01506c8c64 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed f5877f72ae83eb7b28893e10db430d01506c8c64 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] f5877f7

Verdict parsed from the review's SHA-scoped output markers for commit f5877f72ae83eb7b28893e10db430d01506c8c64.

False positive or not applicable? A repository writer can comment:
/ai-review override fable f5877f72ae83eb7b28893e10db430d01506c8c64 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of f5877f72ae83eb7b28893e10db430d01506c8c64 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • The test now depends on the exact text of the "crewmate prune still waiting" warning. If someone rewords it, release is never set, so the holder keeps the lock for its full 5 s and lock_waits >= 2 still passes. The new not other.is_alive() assertion does not catch this, because the holder has already finished by then. Asserting expired_waits >= 2 would make a reworded warning fail the test.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 6, 2026
@iamwhatever iamwhatever self-assigned this Nov 6, 2026
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>
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: passed Eligible automated validation passed for the current revision readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 6, 2026
@chenmingwei23
chenmingwei23 merged commit 1120304 into main Nov 6, 2026
97 of 110 checks passed
@chenmingwei23
chenmingwei23 deleted the greener/pr-23389 branch November 6, 2026 03:15
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants