Skip to content

Live-edge subscriptions replay the outage after reconnect #2784

Closed

Description

@kixelated

Problem

A live subscription opened with subscribe(None) / group_start: None is documented to start at the latest group. After a reconnect, the same subscription instead requests every group since the last group observed before the outage.

For live playback, this produces a burst of stale frames that downstream QoS drops while the subscriber catches up to the live edge. The longer the outage, the larger the burst, up to the publisher's retention window.

Observed with moq-relay 0.14.8-c8b11b10b after restarting the relay:

FIRST: Dropping frame due to QoS. start:0:07:19.485031770 deadline:0:07:19.485031770 earliest_time:0:07:31.148510106
...
LAST:  Dropping frame due to QoS. start:0:07:31.129998770 deadline:0:07:31.129998770 earliest_time:0:07:31.148510106

Approximately 12 seconds / 350-355 frames were replayed and dropped in about 3 seconds. Longer stop/start intervals produced thousands of dropped-frame messages.

Expected behavior

A subscription whose group_start remains None should return to the live edge after reconnect, matching the documented meaning of None. It should not implicitly become a catch-up subscription.

If gapless catch-up across reconnects is required for other consumers, it should be an explicit policy rather than changing the meaning of the live-edge default.

Root cause

This is resume slicing layered on top of subscription aggregation:

  1. moq_native::Client::consume configures origin linger so a relay restart preserves the logical broadcast and subscription across reconnects.
  2. model/resume.rs::Producer::takeover creates a new segment starting at one past the newest group observed on the previous segment.
  3. model/resume.rs::slice maps (prefs.group_start = None, segment.start = Some(n)) to group_start = Some(n).
  4. That explicit bound enters the track subscription aggregate.
  5. The moq-lite subscriber forwards it upstream as Subscribe.start_group.
  6. The moq-lite publisher uses the explicit start instead of track.latest(), replaying the missed range.
  7. Hang media tracks advertise a 30-second retention window, so a substantial missed range can still be available.

The existing model::origin_impl::tests::test_linger_reconnect_splices regression test currently asserts this behavior: a subscriber initially created with subscribe(None) reconnects with producer.subscription().group_start == Some(2). The focused test passes on current main, so the behavior remains present.

Reproduction

  1. Publish a Hang video track through a relay.
  2. Consume it through a reconnecting moq-native client with the default subscribe(None).
  3. Let playback reach steady state.
  4. Stop the relay for several seconds, then start it again within the reconnect/linger window.
  5. Observe that the resubscription requests from the last group received before the outage and rapidly replays the missed media instead of starting from the latest group.

Fix considerations

The public semantic and the existing reconnect promise currently conflict:

  • group_start: None says to start at the latest group.
  • Origin resume promises to splice a reconnect at the first missing group.

The default should likely preserve live-edge semantics through every segment. Consumers that need catch-up should opt into it explicitly. The implementation and API shape need to preserve both use cases without overloading None.

A regression test should cover a lingering/reconnecting default subscription with multiple groups produced during the outage and assert that only the live edge is delivered after reconnection.

(Written by GPT-5)

Activity

  1. coderabbitai commented on Aug 12, 2026

    @coderabbitai
    Contributor
    ⚠️ Possible Duplicate Issue(s)
    🔗 Related PRs

    #1137 - Revert next_group to recv_group rename [closed]
    #2500 - fix(net): tear down idle upstream subscriptions [merged]
    #2534 - fix(moq-net): deliver groups from a takeover source that restarted its numbering [open]
    #2537 - feat(net): start and end subscriptions and fetches at a specific frame [merged]
    #2771 - fix(net): serve subscriptions in arrival order so reordered groups aren't dropped [open]


    📝 Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  2. kixelated commented on Aug 15, 2026

    @kixelated
    CollaboratorAuthor

    Heads up that #2785's fix is being reverted on dev in #2852, and will reach main at the next dev merge. The diagnosis here was right; the fix is moving layers rather than being withdrawn.

    #2785 stopped the replay by making a takeover boundary never become subscription demand. On dev that is not available: boundaries are frame-precise, and since the read cursor is group-granular the frame offset can only reach the replacement as demand. Under #2785's rule takeover_splices_mid_group and takeover_redelivers_an_incomplete_frame both fail, so a track whose current group never rolls (a JSON append log, a catalog with deltas) cannot survive a route change at all.

    The framing that settles it: start/end are filters, not requests for reliability. A takeover boundary entering the demand aggregate is not a request to replay an outage, and the ceiling on how much gets replayed belongs to the latency budget. A backlog also looks exactly like congestion from the subscriber's side, and the answer to congestion is the ordered consumer skipping ahead, not a special case in resume.

    What actually changes for this report:

    • The repro here cannot recur. Its root cause step 1 is origin linger holding the broadcast alive across a relay restart; dev removed linger in fix(net): remove linger; a broadcast closes with its last source #2704, and detaching the last source now closes the broadcast synchronously. A single-relay restart ends the subscription instead of splicing.
    • A narrower path stays open: a preferred route that stalls while still alive, with a standby advancing behind it, leaves the boundary trailing the standby's live edge by more than failover latency. That needs a cluster or redundant publishers, not the single relay here.

    The real fix is to enforce Subscription::latency in moq-net rather than only in moq_mux::container::Consumer, so a relay hop, a moq-json track, and a raw track::Subscriber are covered too: capped by Info::latency_max, preferring the moq-lite-05 presentation timestamp with a creation stamp as the fallback, applied at both the publisher (aggregate, saves the bandwidth) and the subscriber (per-subscriber, exact). That is a follow-up PR; this issue is the reason it exists.

    (written by Opus 5)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions