Repository navigation
Description
Summary
backend-unit-test.yml installs pytest-timeout but never passes --timeout, so a single hanging test consumes the job's entire 25-minute budget. The job is then cancelled by timeout-minutes: 25, the JUnit upload step is skipped, and the failure surfaces as an opaque ##[error]The operation was canceled against whichever PR happened to be running.
It has now hit the base side — i.e. unmodified dev — so it is not branch-specific and can redden arbitrary PRs.
Evidence
| Job | Side/seed | Duration | Outcome |
|---|---|---|---|
| 92259006786 (PR #1952) | base, 67890 | 25m | cancelled at 81% |
| 92250694744 (PR #2010) | head, 99999 | 25m15s | cancelled at 96% |
Sibling shards of the same commits finish in ~10m, so this is not general slowness. The logs show the suite stalling, not crawling — on the #1952 job there is a 3m37s gap between two progress lines with no output at all:
2026-08-05T09:30:42 ........................................ [ 79%]
2026-08-05T09:34:19 ........................................ [ 80%]
2026-08-05T09:35:34 ##[error]The operation was canceled.
That is the signature of one test blocking, not of a slow runner.
Why it is worse than a slow job
- No per-test attribution. The run dies without naming the test that hung, so each occurrence costs a manual log dig, and nothing accumulates toward finding the culprit.
- The artifact is lost.
Upload JUnit XMLhas noif: always(), so on cancellation it never runs.diff-pytest-failures.pyis deliberately fail-closed on a missing XML, which is correct — but it means one hang turns into a second, differently-worded failure on theregression diffjob. - It lands on innocent PRs. A base-side cancellation is a property of
dev, not of the PR under test, but it is the PR that goes red.
Suggested fix
Pass a per-test timeout in the existing invocation — the plugin is already installed (tests/requirements-test.txt:4), so this is one flag:
python -m pytest unit/ -m "not slow" \
--timeout=60 --timeout-method=thread \
-p randomly --randomly-seed=${{ matrix.seed }} \
...A hang then fails that test, by name, in 60s, the suite completes, the JUnit XML uploads, and the regression-diff job reports it as an ordinary new failure. The culprit becomes visible instead of inferred.
Worth adding if: always() to the upload step as well, so a partial XML still reaches the diff job rather than being silently absent.
--timeout-method=thread rather than the default signal method because parts of this suite run their own event loops; the signal method cannot interrupt a blocked C call, which is the case most likely to be at fault here.
Acceptance criteria
- A hanging unit test fails by name rather than cancelling the job
- The 25-minute job timeout stops being reachable through a single test
- JUnit XML reaches the diff job even when the pytest step ends abnormally
- The specific test(s) responsible for the two cancellations above are identified once the timeout makes them visible
Related
- fix(tests): resolve 20 remaining unit test failures post-#589 #660 — the documented pre-existing failures the
|| trueaccommodates - bug: test_a13_exact_cutoff_row_is_not_expired is wall-clock flaky (~3.3%), reddens regression diff on unrelated PRs #1909 — a wall-clock flake in this suite; same "seed-dependent, machine-dependent" family
Activity
dolho commentedon Aug 5, 2026
Correction to the issue body — this is not seed-specific, and I said so too early.
Two more occurrences since filing, plus a re-run result that contradicts my original framing:
So: all three seeds, both sides, four different PRs. I had written that the twice-hit
base, seed 67890shard implied a specific test ordering. That is wrong — the third and fourth occurrences are different seeds, and more decisively, re-running the exact same seed-67890 base job passed (#1952 is now green with no code change). Same ordering, different outcome, so ordering alone is not sufficient.What the evidence actually supports:
None of this changes the fix, and it strengthens the case for it: with
--timeout=60 --timeout-method=thread, an intermittent 3-minute block fails that test by name instead of consuming the 25-minute budget and dying anonymously. Right now every occurrence costs a manual log dig and yields no accumulating evidence about which test is responsible — which is exactly why I was able to guess wrong about the cause.--timeout-method=threadmatters more given the stall shape: if the block is inside a C-level socket wait, the default signal method cannot interrupt it.dolho commentedon Aug 5, 2026
/claim
github-actions commentedon Aug 5, 2026
Claimed by @dolho. Label
status-in-progressadded.Next steps:
feature/2019-<short-slug>Fixes #2019dolho commentedon Aug 5, 2026
Handled in #2021 — with both of my recommendations in this issue corrected, because measuring contradicted them.
60s was wrong and would have caused an outage. Pulled the real durations from a green run's JUnit instead of guessing:
test_start_agent_skip_inject's two retry cases legitimately run 60.62s and 60.57s (three real connection retries), then 39.9s and 26.6s intest_1083_result_callback. A 60s cap fails those two on every PR. And the cap has to survive the very runner variance this issue is about — a 2.5x-slow shard puts a 60.6s test near 150s — so it landed at 300s, which still converts a multi-minute stall into a named failure with ~5 of them fitting in the budget.threadwas wrong too. I justified it here by saying SIGALRM cannot interrupt a blocked C call. That is the docs' caveat, not a fact about this suite, and I should have tested it before recommending it:More importantly
threadis the worse outcome even when it works: it dumps stacks and kills the process, so the run aborts, the JUnit is incomplete, and the diff job fails with no complete comparison — just a named culprit in a log.signalraises inside the test and the suite continues, so the diff job reports the hang as an ordinary new failure by name. The logs back that shape: #1952 kept progressing after its 3m37s gap, so these are stalls that release, not one permanent hang.Scope note: #2021 covers
backend-unit-test.ymlonly.backend-unit-nightly.ymlhas the same 25-minute budget and wants the same two lines, but PR #1952 is open against that file — better applied there than shipped as a conflict.fix(ci): give the unit suite a per-test timeout so a hang names itself (
fix(deploy): keep archive-storage construction cheap and DB-free (#2205)
fix(deploy): give /data/archives an owner, so log archival stops dyin…
test(ci): bound the #1941 branch check on a shell token, not the subs…
ci(nightly): make the cross-PR regression net able to finish, and una…
ci: restore the unit suite's timeout headroom — 25 -> 45 minutes
ci: parallelise the unit suite with xdist instead of raising the cap …
merge-train: learnings.md keep-both + _git fail-soft on a hang (#2816)