Skip to content

fix(net): a restarted publisher wins over its lingering session at once - #6452

Merged
kixelated merged 2 commits into
mainfrom
fix/restart-wins-lingering-session
Oct 23, 2026
Merged

kixelated merged 2 commits into
mainfrom
fix/restart-wins-lingering-session

Conversation

@kixelated

@kixelated kixelated commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

A publisher that restarts without a clean close (SIGKILL, flaky uplink) leaves its old session on the relay until QUIC idles it out. The new process announces under a new first hop (its own random origin id). The default wire, moq-lite-06, carries no epoch: only lite-07 does, and it is opt-in, so even main's moq, which mints one, arrives epochless. The two routes then tie on everything up to route_order's Spread Hash, which picks the dead session half the time.

A viewer that requests the path in that window lands on the dead session. Its catalog.json TRACK_INFO waits about 10 s, then fails Unroutable when the session idles out. A client that does not follow the Restart, such as moq export, exits.

Local repro: one moq-relay, ffmpeg | moq import fmp4, SIGKILL both, restart the publisher at once, then moq export fmp4 1 s later. On main, 9 of 18 runs fail with moq 0.14.2, and 2 of 6 with main's own moq.

Approach

route_order no longer hashes a route that entered on this origin (Link::Local: an in-process producer or a client session) at the requested path. No other node ranks that route, so convergence does not need the hash, and Reverse(id) lets the newest announcement win.

The hash still applies to:

  • Peer and upstream routes, so every node converges.
  • A prefix claim resolving a path beneath it, so a directly connected pool still spreads its paths (equal_cost_pool_spreads_paths is unchanged).

With this PR, the repro answers the catalog within ~20 ms in 12 of 12 runs.

Tests:

  • New replacement::restart_while_the_old_session_lingers_wins: the old session goes silent, the publisher restarts under another hop, and a viewer subscribes. It runs both hop orders on lite-06, lite-07, and moq-transport-22. Without the fix it fails with subscribe hung.
  • an_equal_cost_replacement_waits_for_the_old_route now pins the peer case, renamed ..._peer_replacement_.... The new an_equal_cost_local_replacement_takes_over_at_once covers the local case.
  • source_flip_restarts and a_restart_pending_when_the_grant_grows_still_restarts announce the competing route from a second local session instead of a peer. A peer route at an exact tie with a local one now loses, since the local one is not hashed.

Impact

  • Public API: none.
  • Wire: none. The moq-lite draft states that a relay skips the Spread Hash for a route a publisher announced to it directly at the requested path, with a lite-07 changelog bullet.
  • Behavior: this reverses the 2026-10-07 decision that equal-cost restarts keep the hash, for a relay's own sessions only. Exact-path replicas without an epoch connected to one relay now go to the newest, so a replica restarting takes the path and restarts its viewers. Replicas that share content should share an epoch.
  • js/net mirrors it: a JS origin never peers, so it leaves any tie at a route's own path to the newest (compareRouteCandidates), and advertisements break a full tie by newest too. The JS pool-advertisement test now asserts that a replacement at its own path wins whatever its hop; an equal-cost pool spreads its paths is unchanged.

Alternatives

Follow-ups

  • moq export 0.14.2 sometimes exits with "rendition 0.m4s went back in time" right after a clean subscribe: 4 of about 45 runs here, including runs that never touched the dead session. It looks like a separate exporter issue. Not investigated.

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

A publisher that restarts without a clean close announces its path under a new
first hop while its old session lingers until the transport idles out. On the
default wire (moq-lite-06) neither route carries an epoch, so the rendezvous
hash ranked the two at random, and requests landed on the dead session: a
viewer waited ~10 s and then failed `Unroutable`.

`route_order` no longer hashes a route that entered on this origin at the
requested path. No other node ranks it, so convergence does not need the hash,
and the newest announcement wins. Peer routes, and a pool claiming a prefix
spreading the paths beneath it, are hashed as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 8 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3eb7f628-6449-4ed1-98bf-7d7d10a8b323
📥 Commits

Reviewing files that changed from the base of the PR and between 12821c4 and f22cf5a.

📒 Files selected for processing: 10
  • doc/bin/relay/cluster.md
  • drafts/draft-lcurley-moq-lite.md
  • js/net/src/consume.ts
  • js/net/src/internal.ts
  • js/net/src/origin.test.ts
  • js/net/src/origin.ts
  • quest/m0/broadcast-epoch/README.md
  • rs/moq-net/src/lite/publisher.rs
  • rs/moq-net/src/model/origin.rs
  • rs/moq-net/tests/integration/replacement.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T03:24:55.415341Z f22cf5a New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5952246a4f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread js/net/src/origin.ts Outdated
A JS origin never peers, so every route it holds entered on it, as a client
session does in rs/moq-net. Leave a tie at a route's own path to the newest
instead of the spread hash, so a reconnect under a new hop wins there too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated added this pull request to the merge queue Oct 23, 2026
Merged via the queue into main with commit a7acf21 Oct 23, 2026
10 checks passed
@kixelated
kixelated deleted the fix/restart-wins-lingering-session branch October 23, 2026 07:41
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