Repository navigation
fix(moq-net): never stitch two broadcasts (release) - #9043
Merged
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
On
release, a publisher that re-creates a broadcast at the same path, behind the same first hop, gets the new broadcast stitched onto the old one. Viewers stall in "loading". A front treated every route from the same publisher as the same content: when its source closed it resumed through the next route, and while serving it spliced a better route in. A re-created broadcast restarts its group numbers (append_group()counts from 0 onrelease), so the resumed track waits for groups past the old head that never come.mainalready tells such broadcasts apart (#7489's instance and epoch, minted per lite-06 announce), but that change is a breaking wire change and cannot come back. This is therelease-line fix: never stitch two broadcasts.Changes
rs/moq-net/src/model/front.rs:source_closedalways ends the front. Before, a named publisher's front reselected and resumed through another route.selectedends a serving front whenever another route becomes best: a better route, a drained serving route, the serving route renamed to another publisher, or a local newcomer. Before, it requested through the new route and spliced it in. Readers re-request and get a fresh front through the table's choice. A front whose route stops qualifying with nothing to replace it (renamed in place, or retracted) ends the same way.A front that ends this way emits
BouncebeforeEnd. The origin then re-announces the exact path (a retraction, then the route again) to every announce cursor presenting it. The table alone shows those cursors no change, so without the bounce a browser holding the ended broadcast stalls offline, and a downstream relay re-subscribes on the same session and splices the new broadcast in at the old position. A path announced only through a covering prefix is not bounced, since that would restart its other broadcasts too.A peer's track copy that dies after delivering now ends the track with the error instead of re-subscribing the same source at the old position. The peer's own front may have ended and a fresh one taken over, so asking again could reach another broadcast. A local broadcast's copy still re-splices, since it is the one broadcast published here.
This matches upstream
mainfor moq-lite-06, where each announce mints its own instance:restart()inlite/publisher.rs), which is this bounce on the wire. It is delivered at once, not held.a_copy_dying_under_a_minted_instance_ends_the_track), while a local broadcast re-splices (recreated_track_*).rs/moq-net/src/model/origin.rs: a request joins a cached front only while the best route is the one the front's source came through, not merely one from the same publisher. Otherwise a request right after a route change joined the front that was about to end.The front never has a second source, so it never reads through a route it doesn't advertise. A version that kept the attached source until it closed was rejected for that reason: the relay would advertise one route while reading through another, which breaks the assumption behind the loop-freedom argument in
origin.rs(fronts waiting on each other in a cycle).Tests (
front.rs,origin.rs):a_returning_publisher_is_never_stitchedis new. A publisher's route returns behind the same first hop before the old front notices it left, and a request gets the new broadcast from its group 0. It fails onrelease("the old subscription waits on the returning publisher: Elapsed").a_better_route_ends_the_fronta_dead_source_ends_the_fronta_local_newcomer_ends_the_fronta_first_hop_update_ends_the_frontdrain_reprice_ends_the_fronta_local_newcomer_ends_the_incumbent_fronta_second_local_source_gets_a_fresh_fronta_hairpin_through_the_plain_front_is_withdrawnan_ended_front_bounces_its_announceis new: whether the source closes under a route that stays or a cheaper route wins, the cursor sees the path retracted, then active. It fails without the bounce.a_covering_route_is_never_bouncedis also new.a_route_renamed_in_place_bounces_its_announceis new: a route updated in place to another first hop shows the cursor only an update, so it fails without the bounce inselected's no-candidate arm.a_second_local_source_gets_a_fresh_frontrequests right after the newcomer attaches. It fails without the route check on joining a front.rejoin.rs(taken_over_quiet_catalog_survives_cache_expiry) andgoaway_cluster.rs(cluster_migrates_on_upstream_goaway,cluster_diamond_goaway_seamless_failover) asserted seamless resumption across a publisher takeover or a relay GOAWAY. They now assert the new contract: the old subscription ends with no group from the new leg, a fresh request reads the new leg, and the path ends up announced, though it may bounce.moq-tokio'sbroadcast_route_migrationis reworked the same way.Impact
doc/bin/relay/cluster.mdsays so.Validation
sh/rs/select.sh checkandsh/rs/select.sh testover this diff (moq-net and every dependant, moq-tokio included): 5195 tests pass, check andcargo fmtclean.origin/releaseand passes here.just checkand the platform lanes; CI covers them.Caused by
Splicing a second route's source into a front came with #2241 (migrate subscriptions transparently across connections) and became the front state machine in #3895. Both assume one publisher hop means one broadcast, which a re-created broadcast breaks.
Models
Size: M
Implementer: Claude Code, claude-opus-5-5, unknown effort
(Written by Claude Opus 5.5)
🤖 Generated with Claude Code
Review
Rewritten by
quest reviewafter each round.Head: 94dd3ac
Base: origin/release at ca3b801
Risk: medium,
the base has no RISK.md to name what is always high or customer-facing, so every change is mediumClassified: medium by default
Reviewer: Codex, gpt-6.1-sol, high effort
Session:
01a1ec58-e1b1-7fe2-bb02-c91d602dddbd, round 4Score: 10/10,
The only incremental change corrects a comment to match the previously reviewed behavior; no findings remain, and builds and tests were not run as instructed.Rounds: 5; first round 2 (high 1, medium 1); findings 2 (high 1, medium 1): fixed 2, refuted 0, open 0
Findings: none
Reviewer: Codex, gpt-6.1-sol, medium effort, shadow
Session:
01a1ec58-e1b2-78f3-8401-3bad1160515bRounds: 2; first round 1 (medium 1); findings 1 (medium 1): fixed 1, refuted 0, open 0