test_a_killed_holder_leaves_no_stale_lock¶
Tests › tests/test_buildlock.py
What this test is for
Why it exists
WHY flock RATHER THAN AN O_EXCL LOCKFILE, proved rather than asserted. A lockfile needs a stale-lock story — a builder killed mid-run leaves the file, and every later process has to decide whether the holder still lives. Getting that wrong wedges a target permanently, which is exactly the class of failure this sequence of releases has been about.
Given
db = tmp_path / "clew.db"acquired = multiprocessing.Value("i", 0)
2 more
child = multiprocessing.Process(target=_hold, args=(str(db), acquired, 60.0))child.start()
When
try: for _ in range(100): if acquired.value: break time.sleep(0.05) assert acquired.value == 1, "the child never acquired the lock — test would be vacuous" child.kill() child.join(timeout=10) ## Immediately acquirable. A short wait proves it is not merely the bound expiring. started = time.monotonic() with build_lock(db, wait_seconds=30.0) as held: assert held is True, ( "the lock was still unavailable after the holder was SIGKILLed — that is a stale " "lock, and it would wedge every later build of this target" ) assert time.monotonic() - started < 5.0, "acquisition after a kill should be immediate" finally: if child.is_alive(): # pragma: no cover child.kill() child.join()
Then
- —
What it exercises
The parts of the system's flows this test ran, measured by per-test coverage: lit steps ran in this test, dimmed ones did not, and ▶ marks where the test called in. Each title opens the whole flow with these steps lit.
thread `clew-first-build-` — `_first_build_worker` (clew/mcp_server/server.py) · 2 of 142 steps
… 60 earlier steps
… 76 later steps
tests/test_buildlock.py:113 · its file's page
What it checks (3)
assert acquired.value == 1, "the child never acquired the lock — test would be vacuous"not attributedassert held is True, ( "the lock was still unavailable after the holder was SIGKILLed — that is a stale " "lock, and it would wedge every later build of this target" )not attributedassert time.monotonic() - started < 5.0, "acquisition after a kill should be immediate"not attributed
Where the product reaches it
No product flow reaches this code: no product entry point's flow calls any of the functions this test calls.
Call flow
What it reaches
Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.
Also reaches 1 requirement
Its run touches their code; that is reach, not proof.
- REQ-DDB-INDEX-002 measured