Repository navigation
test(codex-process-lock-store): wait for the lock holder's whole reply lines - #3901
Conversation
…y lines The lock holder is python3 -u, whose print writes a word and its newline as two writes. The test took any pipe chunk as the next reply, so a read that ended between "ready" and its newline let the following read return the stale newline before the child had handled "unlock": the lookup then still saw the exclusive lock (hosted Fast checks, run 43717080636, line 89). Each reply is now read as a whole line and checked to be the word the child sends from the state it promises.
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
Merge passMerged head
One reviewer: test-only. Test-only, one file. The failure it fixes was reproduced before merging: with the child's word and its newline forced 0.3 s apart, Left open, not blocking (LOW): when the child dies early the error does not include its stderr. Review reports: ~/.cache/ovis-tmp/reports/ |
Summary
server/codex-process-lock-store.test.tsfailed in Fast checks on a GitHub-hosted runner: run 43717080636, job 132820955312 (PR #3738 at 81d4d3f). The failing test was "resolves a resumed project rollout with its exclusive writer lock and no database", at line 89. It expectsnullafter the child released its lock but got the project store, and the test took 33 ms. Nothing else in the file failed.The lock holder is
python3 -u. With unbuffered stdout,print('ready', flush=True)is two writes:write(1, "ready"), thenwrite(1, "\n")(seen withstrace). The test waited withreader.read(), which resolves with whatever one pipe read returns, not one line. When a read ended between "ready" and its newline, the read meant to wait for the reply tounlockreturned the stale newline at once. The lookup then ran while the child still held its exclusive lock. The child already locks before it saysready, so the fixture's order was right. The test was reading partial replies. The product is not at fault:flock(LOCK_UN)drops thelock:line from/proc/<pid>/fdinfobefore it returns.The test now reads each reply as a whole line and checks it is the word the child sends (
ready,done). It reads the same wayfirstLineincodex-processes.test.tsdoes, and an early exit fails with what the child wrote. What the test proves is unchanged, with no sleeps; the test's own timeout bounds the wait.Validation
Forcing (scratch, not committed): in the child script,
print('ready', flush=True)is replaced with its two writes and a 0.3 s pause between and after them (sys.stdout.write('ready'); time.sleep(0.3); sys.stdout.write('\\n'); time.sleep(0.3)). That holds open the gap a slow runner leaves between the two writes.codex-process-lock-store.test.ts:89,expect(received).toBeNull(), received the project.codexstore.readyand bothdones, 0.3 s between word and newline), main fails at line 94, the mirror case: afterlock, the lookup ran on the staledonebefore the child relocked and gotnull.openProcessCodexHomecounting an open writer-lock file as held (scratch mutation, reverted), the test fails at line 89 and the unlocked and shared cases fail at line 82.Unforced:
bun test --rerun-each 20 ./server/codex-process-lock-store.test.ts: 200 pass, 0 fail.bun run check fastpasses.Skipped: Integration and browser, Native Windows install, macOS (no product code or other test changed). No changelog fragment, because the change is test-only.