Skip to content

fix(moq-net): a restart away and back before the next poll is an update - #9108

Open
kixelated wants to merge 2 commits into
mainfrom
fix/route-restart-same-instance
Open

kixelated wants to merge 2 commits into
mainfrom
fix/route-restart-same-instance

Conversation

@kixelated

@kixelated kixelated commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Nightly route-sweep and benchmark_route_mesh fail with RESTART to the same instance: a route cursor delivered Restart(C) twice in a row.

The winner at a relay went C -> B -> C before the consumer polled. B is the superseded instance of a restarted publisher, briefly back through a stale path. The first flip queued Restart(B). The flip back kept the pending entry a Restart, now naming C, which the consumer already held. RouteKind::Restart means another instance, so a consumer keyed on it tears down and rebuilds a stream that never changed.

Approach

The consumer state's delivered set becomes a map from prefix to the instance last delivered there. apply_restart onto that instance queues an Announce, which is delivered as an Update (held like any metadata change), whatever was pending.

Impact

  • No public API or wire change. A route that restarts away and back between polls now reaches the consumer as an Update instead of a Restart to the instance it already holds.

Validation

  • New unit test restart_away_and_back_is_an_update: fails on main with the duplicate Restart, passes with the fix.
  • MOQ_ROUTE_SEED=255657690 MOQ_ROUTE_CASE=41 (the nightly failure) replays green; full 500-case sweeps with seeds 255657690 and 7 pass.
  • benchmark_route_mesh (fixed seeds) fails at 61f8956839 and passes at its parent and with this fix.
  • just ci passes. One earlier run hit moq-gst a_protocol_violation_redials_after_playback ("sink dropped 2 as late"). That test passes 3/3 when run alone and in a full rerun, so it is a load-sensitive flake that this change doesn't touch.

Caused by

  • moq-dev/moq#8987 - its new lite-07 route rule lets a relay's winner flip back to a superseded instance through a stale path, which exposed the gap (found by check: nightly benchmark_route_mesh and route-sweep). The coalescing gap itself is as old as pending-Restart coalescing in OriginConsumerState::apply_restart.

Alternatives

  • Track the delivered metadata too, and drop an away-and-back that changes nothing instead of sending an Update. That costs a second copy of every delivered route's metadata to save a rare message.

Follow-ups

  • The transient flip to a superseded instance (C -> B -> C) is coalesced away here. A consumer that polls between the flips would see a regression to the older instance, which the sweep's NoRegression rule would flag. Whether the lite-07 route rule should keep a superseded instance's stale path from winning at all needs a decision.

Models

Size: S
Implementer: Claude, 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: 46c9a33

  • Base: origin/main at ee08224

  • 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, medium effort

  • Session: 01a1f054-de5d-7942-95a5-cb68cb5b8ea9, round 1

  • Score: 9/10, The coalescer correctly handles returning to the last delivered instance while preserving explicit retractions, with regression coverage and no actionable defects found by source review; tests were not run as instructed.

  • Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

kixelated and others added 2 commits November 18, 2026 12:01
…te, not a restart to the same instance

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 18, 2026 20:25
@coderabbitai

coderabbitai Bot commented Nov 18, 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 4 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: 0480f5a8-367c-4ab3-bdd1-309d6d7f9310
Commits

Reviewing files that changed from the base of the PR and between ee08224 and 46c9a33.

Files selected for processing: 1

  • rs/moq-net/src/model/origin.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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Approach: sound. The fix records the instance the consumer last got in delivered. A restart that returns to that instance before the next poll then becomes an Update, so the consumer no longer gets a Restart naming the instance it already holds. This fixes the coalescer where the bug lives, and costs one Instance per delivered prefix.

Reviewed changes

This run reviewed the single-file change to the origin consumer's coalescing state and its regression test.

  • delivered tracks the instance: BTreeSet<Path> becomes BTreeMap<Path, Instance>. take_update stores meta.0.3 when it delivers an Announce or Restart, and every membership check moves to contains_key.
  • apply_restart back to the held instance: the new arm sits after the Unannounce/UnannounceAnnounce arm, so a pending retraction still wins. Otherwise it queues PendingUpdate::Announce, which goes out as RouteKind::Update under the normal update hold.
  • Consistent identity: the origin table only calls apply_restart when previous.instance != entry.instance, so it decides restarts by instance alone. Comparing only the instance (not the epoch) in delivered matches that. owe() treats a pending Announce on a delivered prefix as not owed, the same as the Restart it replaces, so sync accounting doesn't change.
  • Regression test: restart_away_and_back_is_an_update sends a flip to a cheaper instance and back before a poll, then checks that the next event is an Update naming the held instance.

The JS Announce.Producer appends events without coalescing them, so js/net doesn't have this bug and needs no counterpart change.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

This branch has not been deployed

No deployments
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