Skip to content

tests: four merge-queue flakes wait on the event, not on timing - #3581

Merged
wshallwshall merged 4 commits into
mainfrom
lander/queue-flakes-2-7d3a
Dec 2, 2026
Merged

wshallwshall merged 4 commits into
mainfrom
lander/queue-flakes-2-7d3a

Conversation

@wshallwshall

Copy link
Copy Markdown
Collaborator

Tests only; no product code changed. Built by a Lander Builder under the owner's instruction to fix the flaky queue tests. Each of these four tests failed once today on a PR that does not touch it, and each failure removed a PR from the merge queue.

  • Sandbox cut-off test (tests/test_sandbox_isolated.py, run 46863103581): re-sends a dispatch that served nothing because its worker or helper came after the cap, up to a 30 s budget. It checks for no second runner call after every dispatch.
  • Durability teardown census (tests/test_durability_hook_push_bound.py, run 46868850826): the census starts 3 s back, because psutil on Linux reads creation times up to about 1.01 s early from btime truncation.
  • Retried-close test (tests/test_backlog2394_database_gate.py, run 46876329705): polls for the close's done callback rather than reading _CLOSING in the same loop pass.
  • SCP stop test (tests/test_dicom_scp.py, run 46854824199): its SCU ends with an abort, because pynetdicom 3.0.4's requestor release() can lose the stopping SCP's abort and wait out its 30 s ACSE timeout. A local induction reproduced the CI TimeoutError.

Each fix was checked with a temporary product mutation that makes the test fail; every mutation was reverted.

Checks run: ruff check, ruff format --check and mypy (linux, tests profile) on the four files; the four files together, 92 passed; each changed test 5 of 5 on Windows. Not run: the full suite, the product mypy legs, e2e-smoke. The durability fix's failing path is Linux-only and was not exercised locally. Legs to read: ubuntu test for the durability and DICOM tests, windows-2025 for the sandbox and close tests.

QA (Builder's own): Level xhigh. Rounds: 2 + 1 unrepaired (round-9a71c4e2b6, round-3c58e1f07a, round-e4b71d0c95). The Builder did not read the tags with review_tag.py, so this is not the review proof; the Lander starts an independent review on this head.

Open findings from the unrepaired round:

  1. Sandbox: the B and C predicates count helpers from the start, so a refusal left over from a retry can satisfy C without C refusing.
  2. Sandbox: no upper bound remains on refusals.
  3. Sandbox: the join loop can miss a helper that appends after the loop.
  4. Sandbox: the budget is checked after a dispatch, so the worst case is about 30 s plus one dispatch against the 60 s watchdog.
  5. DICOM: assoc.abort() is not guarded by is_established.
  6. DICOM: the SCU recipe is duplicated inside the test body (kept there so it does not overlap PR 3556).
  7. DICOM: the release-to-a-stopping-SCP path loses its only (hang-shaped) coverage.
  8. Close test: one await asyncio.sleep(0) would be exact where the 5 s poll is loose.
  9. Durability: 1.5 s would do where 3.0 s is used.

Product finding to file, not fixed here: DicomScuDestination._release in messagefoundry/transports/dicom.py has the same pynetdicom release race, so a peer that answers a release with an abort would hold the delivery worker for timeout_seconds after a store that already succeeded.

test_cut_off_waiters_never_start_a_second_call_on_a_hung_connection
assumed each of its three dispatches reaches its lookup inside the 4.0s
wall cap. On a loaded windows-2025 runner (CI run 46863103581) the first
dispatch's cap fired before its worker sent the lookup (kill cause
wall_cap, not wall_cap_lookups), so dispatch B became the hung call and
only C refused: `assert 1 == 2` on the refusing helpers.

A dispatch that served nothing proves nothing either way, so the test
now sends it again until the visible effect it is there for appears: a
runner call for A, one more refusing helper for B and for C, within a
30s budget inside the watchdog. Each dispatch must still hit the cap,
and the guarded property is checked after every dispatch: no second
runner call on the hung connection. A temporary mutation that skips the
per-connection record (B calls the runner) fails the test.

Verified-by: tests
… truncation

test_the_TEARDOWN_ends_a_SUSPENDED_process_frozen_before_it_ran failed
to arm on ubuntu (CI run 46868850826): "the teardown census did not see
the frozen process". The census skips processes created before `since`,
set 1.0s below time.time(). On Linux psutil reads a creation time as
/proc/stat's btime, truncated by the kernel to whole seconds, plus the
start time truncated to clock ticks, so a process can read up to about
1.01s early. One started within a tick of the cut reads as older, and
psutil caches that value, so every poll for 15s skipped it.

The census, the token fixture's teardown census and the import cut now
start CENSUS_MARGIN (3.0s) back. The needles (token, sleeper mark,
temporary directory) alone tie a process to its test, so the wider
window admits no other test's process, and the test still requires the
census to see the frozen process before it asserts the reap.

Verified-by: tests
Verified-by: code-review xhigh
test_a_retried_close_waits_on_the_close_already_in_flight read
database._CLOSING right after `await asyncio.wait_for(retry, WAIT)`.
The close drops its entry in a done callback queued when wait_closed
ends. On a loaded windows-2025 runner (CI run 46876329705) the retry's
0.1s tick timer woke it in the same loop pass, ahead of the close's last
step, so the retry ended before that callback ran. The test task, woken
by the send in that pass, found `retry` already done, the await returned
without yielding, and the read saw the entry: "a finished close is
still tracked".

The test now polls with the shared wait_until (up to WAIT) for the entry
to go. Removing the _forget_close callback in a temporary local mutation
still fails the test.

Verified-by: tests
test_scp_stop_runs_off_loop_and_lets_in_flight_cstore_finish timed out
on ubuntu (CI run 46854824199) waiting 15s for its SCU thread. The SCP
is stopping when the SCU releases, so it ends that release with an
abort at once. pynetdicom 3.0.4's requestor can lose the abort:
release() pauses the reactor by trusting _is_paused, which still reads
True for the reactor send_c_store has just woken, and that reactor's
next pass takes the abort off the queue. release() then waits out the
SCU's 30s ACSE timeout. A local induction (requestor reactor 50 ms late
to its abort check, release waiter 200 ms late) reproduces the CI
TimeoutError with the old helper and passes with this change.

The test's SCU is now an inline copy of _scu_cstore that ends with an
abort, kept inside this test's body so it merges cleanly with PR 3556's
edits to the helper. The C-STORE status is read before the SCU ends, so
every claim holds: a stop that aborts the in-flight association (a
temporary local mutation calling AE.shutdown) still fails the test.

Verified-by: tests
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander (session heuristic-kepler, account 7): independent Lander-started review of this Lander-built PR (fork aee3f4fa814451266, round-71e0c9a4d3): xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings (review_tag.py exit 0). Four test files only, nothing outside tests/. Each fix addresses its CI timing cause. Five temporary product mutations were each caught and restored: a refusing waiter calling the runner; a cut-off refusal dropping the busy record; skipping the wait on the in-flight close; never forgetting the close; stop aborting in-flight associations; teardown ending nothing.

One finding makes a test weaker than on main: the DICOM stop test's SCU now ends with abort, so nothing exercises a peer A-RELEASE to a stopping SCP. On main that path was reached only as a side effect, and its only signal was a hang that could not be told from the pynetdicom 3.0.4 requestor race this PR avoids. Decision d20261202T140825539-874b57 (class B): merge and file it. Undo: revert the squash commit.

Queued for filing under R2 (one row): a raw-socket SCU test that sends A-RELEASE-RQ after the C-STORE-RSP and bounds stop(); the sandbox phase predicates use absolute counts (use a per-phase snapshot); the 30 s sandbox budget ignores the respawn outside the cap; cstore_then_abort duplicates _scu_cstore; the DICOM finally never sets release_commit; phases B and C share a failure label; the Builder's nine open items in the PR body. Product row: DicomScuDestination._release calls assoc.release() right after send_c_store, the same sequence as the race, so a peer that answers a release with an abort would stall a delivery lane for timeout_seconds per object on first deployment.

Pinned head for the merge: 2358f14. I enqueue once every required context is green on it.

@wshallwshall
wshallwshall added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit 0a367fd Dec 2, 2026
62 checks passed
@wshallwshall
wshallwshall deleted the lander/queue-flakes-2-7d3a branch December 2, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant