Repository navigation
fix(net): a read that finds the end settles a waiting live join first - #9810
Conversation
Quest-Claim: 071ca1bf1fe5726b
A received lite-07 copy's live join waits on its upstream only until the copy's end is declared. When SUBSCRIBE_END landed on another thread between a read syncing its window and walking the track, the walk passed the held group (the window still reaching) and then found the track complete, so the read ended with no group: the interop finish lane's empty health and video tracks under load. Both reads now re-settle the window when the walk finds the end, not only when it is pending, and walk again if it moved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…5/finish-go-row-under-load # Conflicts: # quest/m0/test-flakes-5/finish-go-row-under-load.md
Review round 1: re-walking in place kept a time start's new lookup unasked (the arrival read then parked with nothing to wake it) and kept an ordered walk's floor past groups the moved window now reaches. Both reads now run again from the top, which syncs, asks lookups, and seeks from the next key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 2's note: each start-over recursed, so a burst of window moves landing between preparation and the walk's end could grow the stack. The walks now report `Walked::Again` and the reads loop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. WalkthroughArrival-order and key-order track reads now retry when end-time synchronization moves the subscription window. A regression test checks both read orders. The change also removes a document that described intermittent interop failures and an investigation plan. Merge Risk:
|
Finishes quest/m0/test-flakes-5/finish-go-row-under-load.md.
Problem
Under load, a reader of a finished track sometimes got nothing, even though the relay held the tail.
That is the
finish go -> *row failing withno health group(seen on #9758) orexpected 10 frames, received 0(seen on #9793), and thefinish cpp -> *row the same way (seen on #9813).The cause is a race in
moq-net'sCursor, in the received lite-07 copy a relay (or a client) keeps.Start::LATEST) on a copy whose upstream answers joins waits for that answer. It does so only while the copy's end is undeclared, so the window "reaches" and admits nothing.SUBSCRIBE_ENDlands on another tokio thread between those two steps, the walk passes the held group (the window is still reaching) and then finds the track complete.Ok(None). The front ends the read, and the publisher sends the reader START/END with no group.With the end declared, a re-sync would have placed the join locally over that group. The existing re-sync after the walk ran only when the walk was pending, not when it found the end.
The race needs the end to land mid-poll on another thread, so the single-threaded kio sim can't reach it, even with
KIO_SIM_SCHEDULE=random. It shows only under multi-threaded tokio with scheduling jitter. Tracing a failing relay confirmed the order: the copy cursor's feed ended with the window still reaching and group 0 cached, and "place live" came right after.Approach
When the walk finds the feed ended and re-syncing moves the window, both reads (
poll_peek_recvfor arrival order,poll_peek_nextfor group order) now start over. That covers the case the old re-sync missed: it ran only when the walk was pending. Starting over means syncing, probing (which sends any lookup a newly resolved time start needs), and seeking again from the committed next key.The walks report a private
Walked { Found, Ended, Again }and the reads loop onAgain, so the stack stays constant. A join that waited on its upstream then places over the held group. Only a read that is still empty after a settled walk ends.JS needs no change. Its
#tryRecvGroupsettles and walks synchronously on one thread, so the end can't land between the two.Impact
Caused by
joins_answered), so a window can move when the end lands, but the reads re-settled only on a pending walk, not on one that found the end (found by check: interop under load).Validation
New unit test
a_read_finding_the_end_places_its_waiting_join_firstdrives the race by hand. It syncs the cursor, declares the end, walks, then reads again, for both read orders. It fails without the fix (the walk reports the end with no group) and passes with it.cargo nextest run -p moq-net --all-features: 4674 passed.cargo clippy -p moq-net --all-features --all-targets -D warnings: clean.just checkon the merged head 621bda3: passed. Later heads changed onlytrack.rs, rechecked with the nextest and clippy runs above.Under load, with the interop finish lane (
just test interop --finish --all --publishers <row>) looped, three runs in parallel, while a script randomly SIGSTOPped the relay and client processes for up to 900 ms. Plain CPU load (stress-ng, CPU pinning, parallel full runs) never reproduced it in about 60 go rows.Every before-fix data loss was one of the quest's symptoms:
no health group,missing session health group,expected 10 frames, received 0,finish did not drain naturally (frames=0 ...),catalog stream ended without a video and an audio track. They hit the rust, go, python, cpp, c, js-native-bun and js-native-node readers. The final runs passed all 2700 cells.The investigation runs also hit
finish go -> js-native-node (exited 124)twice: the reader printedfinish clean ... health=okand then didn't exit. That is js-native-finish-reader-exit.md, not this bug, and it didn't recur in any of the 1350 reps above.I confirmed the order of events from a failing relay's trace, using scratch instrumentation that is not in this PR. The copy cursor's feed ended with the window still reaching and group 0 held, then "place live".
Decisions
finish_atruns. The end lands on the producer, which doesn't own the readers' windows.AGENTS.md.Cursor, not a sim or interop test. The sim is single-threaded and can't land the end mid-poll, and an interop test reproduces it in only about 3% of reps under SIGSTOP jitter.poll_peek_*call. That needs a test-only hook in the read path, to cover a three-line mapping (Walked::settled).0 of 10 finished frameson the go row looks like this same race (moqsrc reads the relay's copy too), but its gst failure never reproduced here, so this PR can't claim it. Rejected: deleting it unverified.Follow-ups
Models
Size: M
Implementer: Claude Code, claude-opus-5-5, unknown (arm A)
Review
Rewritten by
quest reviewafter each round.Head: e869e9d
Base: origin/main at e1dd5f6
Risk: medium,
The change is a private read-loop fix in rs/moq-net/src/model/track.rs (new private `Walked` enum, poll loops restarted on a feed end) plus a test and a deleted quest plan, keeping every public API and wire format, so it is a fix the next cut publishes as a patch; if wrong, a read could hang or miss a group for subscribers of shipped relays and clients, but the repository's tests and a revert of the commits undo it.Classified: medium by Claude Code, claude-haiku-5-5, low effort, session
18642fbb-0ab3-4b07-8a55-fe57721c15f7Risk file: bb7b1c0de60b
Reviewer: Codex, gpt-6.2-sol, high effort
Session:
01a221c5-f584-7af3-a666-c9101537cbc1, round 3Score: 10/10,
The iterative EOF retries preserve both fixes without growing the stack, and no blocking regressions were found.Rounds: 3; first round 2 (medium 2); findings 2 (medium 2): fixed 2, refuted 0, open 0
Findings: none
Notes, the author's to take or leave:
rs/moq-net/src/model/track.rs:21431:Exercise the EOF retry within a single read🤖 Generated with Claude Code
(Written by Claude Opus 5.5)