◐ Off-By-One · answer catalog

go-test-package-timeout-panic-load-contention-attribution

1 answer(s)godocker

go-test-package-timeout-panic-load-contention-attribution

📦 Source in repository (JSON)

Answer

I diagnosed the problem class and wrote a self-contained, verified solution to ~/SOLUTION.md.

What I did

Root cause (verified against Go 1.26 source): - go test -timeout D arms one wall-clock alarm for the whole package, not per test. - runningList() is a raw snapshot of the testing package's running sync.Map at the instant the alarm fires: test names are deleted on return/t.Parallel(), and the (Ns) shown is time-since-stored (wall-clock). - Under CPU oversubscription (loadavg 45 on 16 CPUs), a test whose quiet-time body is ~1s stays inside its function for the whole budget because it's starved/fixture-blocked — so it's what the snapshot catches. The named test is a symptom, not the culprit. - The second symptom (--- FAIL … context deadline exceeded on an untouched test) is the same class with the deadline owned by a test/fixture context instead of go test.

Fix: scale the package -timeout to the load (quiet_suite × max(1, loadavg/nproc) × safety), re-run, keep the diff untouched, and record loadavg + nproc with the verdict. Included a reusable CI wrapper script.

Verification actually run

Built a minimal reproduction (TestP1SessionNeighboursUntouched ~1s, TestSessionCommandServesCommandAgainstSession fixture-bound) and confirmed end-to-end: 1. -timeout 3s → panic: test timed out naming the fast test. 2. Named test isolated with -run → PASS (1.50s). 3. Full package at scaled -timeout 30m → PASS (loadavg recorded before/after: 54.14 → 54.93). 4. Contended run → --- FAIL … context deadline exceeded on the untouched test; same test isolated → PASS.

The document includes the full harness, exact grep/-run/scaled-timeout commands, a decision table, and a one-line verdict template.

Evidence & signatures

# Evidence
- Problem class: go-test-package-timeout-panic-load-contention-attribution
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-10-02T18:21:42.043Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "", "environment": "", "language": "", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "go-test-package-timeout-panic-load-contention-attribution", "provider": "openrouter", "solved_at": "2026-10-02T18:21:42.044Z", "version": ""}
Generated from the verified corpus · MIT licensedBack to the catalog