Skip to content

fix(moq-net): never stitch two broadcasts (release) - #9043

Merged
kixelated merged 6 commits into
releasefrom
fix/release-no-resume
Nov 18, 2026
Merged

kixelated merged 6 commits into
releasefrom
fix/release-no-resume

Conversation

@kixelated

@kixelated kixelated commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

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 on release), so the resumed track waits for groups past the old head that never come.

main already 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 the release-line fix: never stitch two broadcasts.

Changes

rs/moq-net/src/model/front.rs:

  • source_closed always ends the front. Before, a named publisher's front reselected and resumed through another route.

  • selected ends 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 Bounce before End. 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 main for moq-lite-06, where each announce mints its own instance:

  • Another instance winning a path makes the lite publisher send an end and a fresh start (restart() in lite/publisher.rs), which is this bounce on the wire. It is delivered at once, not held.
  • A copy dying under a minted instance ends its track (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_stitched is 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 on release ("the old subscription waits on the returning publisher: Elapsed").
  • Tests that asserted resumption or a splice now assert that the front ends and a new request gets a fresh front:
    • a_better_route_ends_the_front
    • a_dead_source_ends_the_front
    • a_local_newcomer_ends_the_front
    • a_first_hop_update_ends_the_front
    • drain_reprice_ends_the_front
    • a_local_newcomer_ends_the_incumbent_front
    • a_second_local_source_gets_a_fresh_front
    • a_hairpin_through_the_plain_front_is_withdrawn
  • an_ended_front_bounces_its_announce is 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_bounced is also new.
  • a_route_renamed_in_place_bounces_its_announce is new: a route updated in place to another first hop shows the cursor only an update, so it fails without the bounce in selected's no-candidate arm.
  • a_second_local_source_gets_a_fresh_front requests right after the newcomer attaches. It fails without the route check on joining a front.
  • rejoin.rs (taken_over_quiet_catalog_survives_cache_expiry) and goaway_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's broadcast_route_migration is reworked the same way.
  • Tests that only exercised a second source's splice are deleted: the takeover and warm-head splicing tests, and the refusals of a successor or replacement copy.

Impact

  • Wire: none.
  • Public API: none. Only crate-private front logic changes.
  • Behaviour: failover across relays is no longer seamless. When the serving route drains (a relay GOAWAY included), dies, or is beaten by a better one, the path bounces. Viewers see the broadcast go offline and come back, and they re-subscribe. In-flight subscriptions drain the old copy until it ends, then end. Before, they were spliced onto the new route, which for a re-created broadcast was wrong. doc/bin/relay/cluster.md says so.
  • Announce churn: a bounce reaches every cursor presenting the exact path, including peer relays, once per front that ends while still routed.

Validation

  • sh/rs/select.sh check and sh/rs/select.sh test over this diff (moq-net and every dependant, moq-tokio included): 5195 tests pass, check and cargo fmt clean.
  • The new test fails on origin/release and passes here.
  • Not run here: the full just check and 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 review after 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 medium

  • Classified: medium by default

  • Reviewer: Codex, gpt-6.1-sol, high effort

  • Session: 01a1ec58-e1b1-7fe2-bb02-c91d602dddbd, round 4

  • Score: 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-3bad1160515b

  • Rounds: 2; first round 1 (medium 1); findings 1 (medium 1): fixed 1, refuted 0, open 0

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant