Repository navigation
fix(net): a relay copy fails loud when upstream's largest group goes backwards #5057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # [M] A refused idle copy withholds its cache at every hop | ||
|
|
||
| ## Goal | ||
|
|
||
| Behind any chain of relays, a returning reader never gets a restarted | ||
| publisher's old group. An idle copy that its upstream refuses before | ||
| answering, or answers below its cache, withholds its cache and ends, and no | ||
| hop answers from a withheld cache. Covers lite-07 and moq-transport; lite-05 | ||
| and 06 carry no largest position and keep today's behavior. | ||
|
|
||
| Today only the relay next to the worker catches the restart (#5057). With an | ||
| edge relay in between, the returning viewer still gets the old group on every | ||
| version: the edge's idle copy is refused, aborts, and an aborted copy lets its | ||
| readers drain the old cache. | ||
|
|
||
| ## Plan | ||
|
|
||
| Facts as of #5057: | ||
|
|
||
| - lite: on lite-05+ the upstream's reset lands in `ServeLoop::poll` | ||
| (`lite/subscriber.rs`) as `ServeEnd::GiveBack(err)`, and `TrackServeRun` | ||
| calls `serving.abort(err)`. An aborted copy is readable | ||
| (`TrackState::readable`, `model/track.rs`), so readers drain the idle | ||
| cache. `Unroutable` is not in `route_failed` (`model/resume.rs`), and since | ||
| #5137 a front on a route without an epoch passes the abort on rather than | ||
| re-splicing. | ||
| - moq-transport: the middle relay waits on `track.poll_live` | ||
| (`ietf/publisher.rs`), but its own copy's abort unblocks that wait, and | ||
| `live_edge` reads `latest()` and `peek_latest`, which ignore the | ||
| `live_floor` that `withhold_cache` raises. Its SUBSCRIBE_OK carries the | ||
| hidden group as Largest, so the edge sees no regression, goes live on its | ||
| old group, and then gets PUBLISH_DONE `InternalError`, which aborts its | ||
| copy without closing the source (`ietf/subscriber.rs`, `subscribe_once`). | ||
| The error-answer branch there also aborts without withholding. | ||
| - Every source of a refusal toward a rejoining copy today: no covering route | ||
| (`model/origin.rs`), a lite-07 epoch mismatch (`model/origin.rs`), and | ||
| #5057's regression. On the wire they can't be told apart: lite resets with | ||
| 0x36, and moq-transport sends DOES_NOT_EXIST, read back as `NotFound` | ||
| (`ietf/error.rs`). | ||
| - lite-07: a group header or a datagram (`lite/subscriber.rs`) makes the copy | ||
| live before START, after which `idle_cached()` returns `None` and the | ||
| regression check is skipped. A lite-07 publisher always writes START before | ||
| the first group. | ||
|
|
||
| Decided 2026-10-08: | ||
|
|
||
| - An idle copy refused before it was answered can't judge its cache, so it | ||
| withholds it, whatever the error. A verdict error closes the source so the | ||
| front ends (#5054's guarantee); a `route_failed` error fails over as today. | ||
| This is right for every refusal source above, and needs no wire change. | ||
| Rejected: matching UNROUTABLE only, which moq-transport can't carry | ||
| distinctly, and a new regression error code, a wire change that doesn't | ||
| help moq-transport. | ||
| - No hop answers from a withheld cache: `live_edge` honors the withheld | ||
| floor, and a moq-transport relay whose copy ended refuses the downstream | ||
| SUBSCRIBE instead of sending SUBSCRIBE_OK with the hidden group. | ||
| - lite-07 defers going live on a group until START. A datagram-only track | ||
| never gets a START, so it keeps the gap, which needs a reader starting | ||
| below the cache; document it as a known limit. | ||
| - Decided 2026-10-08: m1, beside the regression check it extends. A relay | ||
| that under-reports its upstream's largest (a cold copy answering from | ||
| older groups) can trip a false regression; that costs a spurious error and | ||
| a re-request, never stale data, and is accepted: cold-relay Largest stays | ||
| INVALID_RANGE (`quest/m0/README.md`). | ||
|
|
||
| Verification: mocked time, a viewer behind an edge relay and the relay next | ||
| to a claim worker that restarts at group 0 within the linger, on lite-07 and | ||
| moq-transport 14, 16 and 22: the returning viewer gets an error and then the | ||
| new output from group 0, never the old group. A lite-07 case where a group | ||
| stream arrives before START. A same-epoch standby still resumes, and a | ||
| `route_failed` refusal still fails over. | ||
|
|
||
| Public API: none expected. Wire: none new. | ||
|
|
||
| ## Related | ||
|
|
||
| - [Announcement takeover](/quest/m1/announce-takeover.md) - a worker that wants readers kept across a restart proves continuity instead of relying on an epochless claim |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When another local requester asks for this path after
source.close()but before the independently spawned origin driver pollsSourceClosed(possible on the normal multithreaded Tokio runtime),OriginState::frontsstill contains a resolved, open front, sorequest_broadcasthands out that old broadcast. OnceAction::Endruns, the newcomer receives an error from the retiring track instead of the fresh front promised by this branch. Source closure and front retirement need an atomic or acknowledged handoff rather than call ordering; the lite regression path has the same race.AGENTS.md reference: AGENTS.md:L64-L64
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Declining. The guarantee is for a reader that saw the copy fail: a reader only surfaces a copy's error through the front's verdict (
resume.rspoll_end: "a copy that failed is the front's to replace"), and the front's wait checksSourceClosedbefore a copy's end, so it detaches the closed source, finds nothing else to select, and leaves the front table before any reader seesUNROUTABLE. That reader's re-request mints a fresh front.The window you describe is a newcomer arriving after
source.close()but before the front task runs. It is indistinguishable from one that joined a moment before the check fired: both are in flight on the old front, both get one error, and the next request is fresh. Neither sees the old output's groups, since the copy's cache is withheld first. Closing that window would need the front table to track each front's serving source, an origin-wide change for a path that only exists to surface a publisher reusing a name, so the PR accepts it.(Written by Claude Opus 5.5)