Repository navigation
tests: the hybrid routes' slot-directory checks are scoped to their own serve, not to /tmp's glob - #1207
Conversation
…wn serve, not to /tmp's glob
`tests/hybrid_route.sh` asserted "no handoff file left in the slot directory" with
[ -z "$(ls /tmp/1bit-hybrid-*/ 2>/dev/null)" ]
which is every hybrid serve's slot directory on the box, not that test's. Another test under `ctest -j` (or
another lane's serve) keeps its own /tmp/1bit-hybrid-* directory alive with a handoff file in it for exactly
the window this check looks, so the test fails while its own directory is clean. Measured, on today's main:
ctest -j2 89 passed, 1 failed out of 90 -- #24 hybrid_route, "FAIL no handoff file left in the slot
directory", with two slot dirs alive and this serve's own one empty
serial the same test passes (twice, 28 s each), which is how the flake reads as a route failure
Deterministic reproducer, no racing: `mktemp -d /tmp/1bit-hybrid-XXXXXX` plus a `handoff.bin` in it, then run
the test -- it fails on that line before the change and passes after it. The same shape was in
`hybrid_kvshare_route.sh`'s "the socket is gone from the slot directory" (a foreign `kvshare-*.sock`).
Both checks now name the directory the serve under test actually owns, read off its child's argv
(`--slot-save-path`, which is `/tmp/1bit-hybrid-*`), so a foreign file cannot satisfy or fail them:
* "no handoff file left in the slot directory" -> `[ -n "$slotdir" ] && [ -z "$(ls "$slotdir")" ]`
* "the slot directory is removed at exit" -> `[ -n "$slotdir" ] && [ ! -d "$slotdir" ]`
(this one used to count the glob before/after, so it passed whenever *some* directory vanished)
The `[ -n "$slotdir" ]` half is deliberate: if the capture ever stops working the checks fail loudly instead
of passing on an empty string. Teeth kept, checked directly: with a file in the serve's own directory the
assertion is false, with it empty it is true.
Gates: `tests/hybrid_route.sh` PASS, `tests/hybrid_kvshare_route.sh` PASS, both with a planted foreign slot
directory present (the failing condition), `ctest -R hybrid -j2` 2/2 twice, `bash -n` clean on both.
Same class as engine#1070 (a CI-only concurrency failure that reads as a route failure); different mechanism
(the slot-directory glob, not the port).
2916909 to
17fea55
Compare
|
Rebased onto current |
|
Composition check, both PRs together on current against 89 passed / 1 failed of 90 for a |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at 17fea557.
The mechanism checks out at the source, not just in the test:
app/serve.cpp:1086-1089makes the directory withmkdtemp("/tmp/1bit-hybrid-XXXXXX")and inserts"--slot-save-path", l.slot_diras two argv elements, sotr '\0' '\n' < /proc/$c/cmdline | grep -m1 '^/tmp/1bit-hybrid-'on the child is the right capture and will not miss an--slot-save-path=/tmp/...form (there is none).- The two assertions the old code got wrong are the two that were glob-bound:
no handoff file left in the slot directoryandthe slot directory is removed at exit(the second counted any directory vanishing, so another lane's serve ending could satisfy it). - The
[ -n "$slotdir" ]half is the part I would have asked for: a capture that silently stops working turns both checks red instead of green, which is the opposite of the bug being fixed.
I did not run the suite end to end here (it needs a built 1bit serve and a fake backend, and a ctest -j sweep is the instrument that found it, not one I can reproduce in one session). What I can say without it: the class is real and the deterministic reproducer you describe — a foreign /tmp/1bit-hybrid-XXXXXX with a handoff.bin in it — is exactly what the old glob could not tell apart from this serve's own directory, and the new checks are scoped to the child's own path. If you want it, the cheapest independent confirmation is mktemp -d /tmp/1bit-hybrid-XXXXXX; touch .../handoff.bin; bash tests/hybrid_route.sh on both commits, which I will run if this comes back to me.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
Follow-up to my READY at 17fea557: I ran the deterministic reproducer I said I would, and it is the before/after the body claims.
mktemp: /tmp/1bit-hybrid-foreign + handoff.bin in it (left in place for both arms), same binary `main` 29ec80c6
main's tests -> FAIL no handoff file left in the slot directory (and "the slot directory is removed at exit (2 -> 1)" passes for the wrong reason: a foreign dir vanished)
this head's tests -> 33 ok, 0 FAIL, with the foreign directory still sitting there
So the assertion now means what it says: the serve under test owns an empty slot directory, another lane's directory is invisible to it, and the exit check no longer passes because someone else's directory disappeared. The slotdir capture works against this engine's argv in practice (--slot-save-path <dir> from app/serve.cpp:1086-1089), so the [ -n "$slotdir" ] half is not silently turning both checks red.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
Root cause
tests/hybrid_route.shasserted "no handoff file left in the slot directory" withThat glob is every hybrid serve's slot directory on the box, not the one belonging to the serve under test. Another test under
ctest -j— or another lane's serve — keeps its own/tmp/1bit-hybrid-*alive with a handoff file in it for exactly the window this check looks at, so the test fails while its own directory is clean.hybrid_kvshare_route.shhad the same shape for its socket check.Measured
Found by a full
ctest -j2sweep on today's main (29ec80c6), not by reading:and at the failure the log shows the give-away: two slot directories alive (
the slot directory is removed at exit (2 -> 0)) while this serve's own one was empty. A redbuildon a PR that touches nothing in this route is what a reviewer has to disambiguate by hand — the same cost engine#1070 records for the port race, via a different mechanism.Deterministic reproducer, no racing needed:
mktemp -d /tmp/1bit-hybrid-XXXXXX+ ahandoff.binin it, then run the test.tests/hybrid_route.shwith a foreign slot dirtests/hybrid_kvshare_route.shwith a foreignkvshare-*.sockctest -R hybrid -j2Fix
Both checks now name the directory the serve under test actually owns, read off its child's argv (
--slot-save-path, which the engine sets to itsmkdtemp):no handoff file left in the slot directory→[ -n "$slotdir" ] && [ -z "$(ls "$slotdir")" ]the slot directory is removed at exit→[ -n "$slotdir" ] && [ ! -d "$slotdir" ]— it used to count the glob before/after, so it passed whenever any directory vanished, including someone else's.The
[ -n "$slotdir" ]half is deliberate: if the capture ever stops working, both checks fail loudly instead of passing on an empty string.Teeth kept, checked directly (not assumed): with a file in the serve's own directory the assertion is false; with it empty, true — captured
slotdir=/tmp/1bit-hybrid-1ll0Ujin the run.Not claimed
RESOURCE_LOCK-style serialisation is not added — it would hide the class rather than scope the assertion, and this is the assertion's bug.Same class as engine#1070; part of engine#698.