relay: install the local forwarder chain on subscribe-created tracks - #546
Conversation
akash-a-n
left a comment
There was a problem hiding this comment.
@akash-a-n reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: 2 of 4 files reviewed, 1 unresolved discussion (waiting on afrind).
src/MoqxRelay.cpp line 1198 at r1 (raw file):
} auto* ready = std::get_if<LocalForwarderRegistry::Ready>(&joined); XCHECK(ready) << "local forwarder entry still pending; a caller failed to resolve its claim: "
copilot flagged a race condition here, where the joinResult would be pending:
- On thread T we have an open subscribe_namespace request
- We get a SUBSCRIBE request on the same thread which then goes upstream and gets suspended
- During this suspension, we get a publish(on a different thread) that fans out thread T through acquireLocalForwarder and the joinResult would be 'pending'
afrind
left a comment
There was a problem hiding this comment.
@afrind made 1 comment.
Reviewable status: 2 of 4 files reviewed, 1 unresolved discussion (waiting on akash-a-n).
src/MoqxRelay.cpp line 1198 at r1 (raw file):
Previously, akash-a-n wrote…
copilot flagged a race condition here, where the joinResult would be pending:
- On thread T we have an open subscribe_namespace request
- We get a SUBSCRIBE request on the same thread which then goes upstream and gets suspended
- During this suspension, we get a publish(on a different thread) that fans out thread T through acquireLocalForwarder and the joinResult would be 'pending'
Aha, good find. I'm going to handle this by dropping a PUBLISH that matches an in-progress SUBSCRIBE. I think it's important because the subscription should get the pinned flag.
2ec50ef to
a243095
Compare
akash-a-n
left a comment
There was a problem hiding this comment.
@akash-a-n reviewed 3 files and all commit messages, and resolved 1 discussion.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on afrind).
a243095 to
c9710fb
Compare
A track created by its first subscriber left no entry in the publisher thread's LocalForwarderRegistry, so a subscriber landing on that thread joined a separate local forwarder instead of the publisher's. First subscriber setup now calls installPublisherForwarder on the publisher executor with removeOnEmpty=true, so the entry is there to find and is dropped with the last subscriber. The initial state for the requesting subscriber is captured from the publisher forwarder, so subscribers joining an existing attachment also get the most recent largest and extensions. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
c9710fb to
4807fa1
Compare
A track created by its first subscriber left no entry in the publisher thread's LocalForwarderRegistry, so a subscriber landing on that thread joined a separate local forwarder instead of the publisher's. First subscriber setup now calls installPublisherForwarder on the publisher executor with removeOnEmpty=true, so the entry is there to find and is dropped with the last subscriber.
The initial state for the requesting subscriber is captured from the publisher forwarder, so subscribers joining an existing attachment also get the most recent largest and extensions.
This change is