Skip to content

fix(net): register subscriptions before exposing track demand - #5991

Merged
kixelated merged 6 commits into
mainfrom
quest/m1/track-status-race
Oct 20, 2026
Merged

kixelated merged 6 commits into
mainfrom
quest/m1/track-status-race

Conversation

@kixelated

@kixelated kixelated commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

A subscribing reader could expose its track request before its subscription was registered. An IETF session could then send TRACK_STATUS and fail the reader when the peer refused it.

Fixes #5954.

Approach

Register subscriptions before publishing requests or demand, preserving the atomic check against idle teardown. The origin front subscribes before querying that same track instance. Remove the obsolete NOT_SUPPORTED fallback to SUBSCRIBE.

A broadcast lookup joins an already-served track after releasing the broadcast lock, so the subscription and first-consumer wakes never run under it: a woken session may re-enter the broadcast. The track's own lock still orders the join against its idle teardown, and a join that loses that race looks the name up again. Joining a queued request stays under the lock and wakes no subscription observer, since only a handler that popped the request can watch its subscriptions.

Deterministic wake-driven tests reproduce both ordering races, including a catalog subscriber against a peer that refuses TRACK_STATUS with 0xFFFFFFFF, and a re-entrant waker that deadlocked when the lookup woke it under the broadcast lock. Query-only and fetch-only refusal tests cover six supported drafts.

Decisions

Codex P2 (wake subscription observers outside the broadcast lock):

  • ✅ Join a served track outside the broadcast lock, retrying the lookup if its idle teardown wins. One change also moves the pre-existing first-consumer wake and a lost race's unregister wake out of the lock.
  • Return the registration wakes from Preferences::register up through resolve_track and wake after the guard drops. Covers only the new wake; the first-consumer wake and the unregister wake still run under the lock.

Impact

  • Public API: unchanged.
  • Wire format: unchanged. Live readers use SUBSCRIBE; refused query-only and fetch-only TRACK_STATUS requests fail without subscribing.

Validation

  • a_subscription_wakes_its_observers_outside_the_broadcast_lock times out under nextest with the lock held across the join, and passes with the fix.
  • The earlier model tests failed before the model fix; the front test independently failed with only the model fix applied.
  • just check passes on the new head.

Alternatives

Waiting or polling in the IETF subscriber and widening the fallback would hide the ordering bug. The request's subscription is registered at its source instead.

Follow-ups

The upstream report about peers refusing TRACK_STATUS remains deferred. The quest stays until that reporting step is resolved.

🤖 Generated with Claude Code

(Written by GPT-6.1-Sol, updated by Claude Opus 5.5)

kixelated and others added 2 commits October 19, 2026 12:47
Register subscriptions before requests or demand can wake their serving session, and derive each subscribed origin query from that same track instance. Remove the TRACK_STATUS fallback to SUBSCRIBE so query-only and fetch-only refusals remain terminal.

Validation: all four deterministic regressions pass, including the scripted peer refusing TRACK_STATUS with 0xFFFFFFFF. The two model regressions failed before the model fix; the front regression still failed with only the model fix. Full moq-net tests are running; just check remains pending. External relay reporting remains deferred under the authorized GitHub organization scope.

Co-Authored-By: GPT-6.1-Sol <noreply@openai.com>
@kixelated
kixelated marked this pull request as ready for review October 19, 2026 23:37
@coderabbitai

coderabbitai Bot commented Oct 19, 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 13 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
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 95392ef9-ebf3-4370-b249-3d160b3221c7
📥 Commits

Reviewing files that changed from the base of the PR and between 173b64e and 9919ac5.

📒 Files selected for processing: 4
  • rs/moq-net/src/ietf/subscriber.rs
  • rs/moq-net/src/model/broadcast.rs
  • rs/moq-net/src/model/origin.rs
  • rs/moq-net/src/model/track.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 19, 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-20T03:30:43.727353Z 9919ac5 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: 6e02817cf1

ℹ️ 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 rs/moq-net/src/model/broadcast.rs Resolved
Registering a subscription wakes the serving session, which may re-enter
the broadcast. Join the live track after releasing the broadcast lock and
look the name up again if its idle teardown wins the race.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated added this pull request to the merge queue Oct 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 20, 2026
kixelated and others added 2 commits October 19, 2026 18:57
Main dropped Demand::poll_used. poll_state arms the same first-consumer
edge while the track is idle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated added this pull request to the merge queue Oct 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 20, 2026
…-race

# Conflicts:
#	rs/moq-net/src/ietf/subscriber.rs
@kixelated
kixelated added this pull request to the merge queue Oct 20, 2026
Merged via the queue into main with commit 916cd45 Oct 20, 2026
11 checks passed
@kixelated
kixelated deleted the quest/m1/track-status-race branch October 20, 2026 03:59
kixelated added a commit that referenced this pull request Oct 20, 2026
#5991 landed the fix and deferred only the upstream reports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

ietf: a TRACK_STATUS refused with any code but NOT_SUPPORTED fails the reader's subscription

1 participant