Skip to content

Use a CPU-time budget for test_lock_contention to fix postgres flakiness#19929

Open
erikjohnston wants to merge 2 commits into
developfrom
erikj/lock-contention-test-timeout
Open

Use a CPU-time budget for test_lock_contention to fix postgres flakiness#19929
erikjohnston wants to merge 2 commits into
developfrom
erikj/lock-contention-test-timeout

Conversation

@erikjohnston

@erikjohnston erikjohnston commented Jul 8, 2026

Copy link
Copy Markdown
Member

test_lock_contention is a performance-regression canary (#16840): the pathological behaviour it guards against spent ~30s spinning the CPU, vs ~0.5s when healthy. The 5s wall-clock alarm it used was calibrated on SQLite, but against PostgreSQL a healthy run already takes 3-4s of wall-clock time (500 sequential acquire/release cycles, each a real database round-trip), so any CI load pushed it over the limit.

Add a cpu_time mode to tests/utils.py's test_timeout, implemented with setitimer(ITIMER_PROF), which budgets process CPU time instead of wall-clock time. Time spent blocked on the database or lost to a loaded CI runner no longer counts, while a regression to CPU-spinning still trips the alarm mid-spin. A healthy run costs <1s of CPU on either database engine; the budget is 10s.

This also subsumes the RISC-V wall-clock carve-out from #18430, which is removed.

erikjohnston and others added 2 commits July 8, 2026 09:52
test_lock_contention is a performance-regression canary (#16840): the
pathological behaviour it guards against spent ~30s spinning the CPU,
vs ~0.5s when healthy. The 5s wall-clock alarm it used was calibrated
on SQLite, but against PostgreSQL a healthy run already takes 3-4s of
wall-clock time (500 sequential acquire/release cycles, each a real
database round-trip), so any CI load pushed it over the limit.

Add a cpu_time mode to tests/utils.py's test_timeout, implemented with
setitimer(ITIMER_PROF), which budgets process CPU time instead of
wall-clock time. Time spent blocked on the database or lost to a loaded
CI runner no longer counts, while a regression to CPU-spinning still
trips the alarm mid-spin. A healthy run costs <1s of CPU on either
database engine; the budget is 10s.

This also subsumes the RISC-V wall-clock carve-out from #18430, which
is removed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019ZdvuLkg7Lm7wDtPQzDnJx
@erikjohnston erikjohnston marked this pull request as ready for review July 8, 2026 10:21
@erikjohnston erikjohnston requested a review from a team as a code owner July 8, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants