Skip to content

relay: move LF forwarder ownership to the publisher exec, off the registry - #522

Draft
afrind wants to merge 1 commit into
feature/lf-subscribe-init-symmetryfrom
fix/lf-trackstatus-local-forwarder
Draft

relay: move LF forwarder ownership to the publisher exec, off the registry#522
afrind wants to merge 1 commit into
feature/lf-subscribe-init-symmetryfrom
fix/lf-trackstatus-local-forwarder

Conversation

@afrind

@afrind afrind commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

In LocalForwarder mode the publisher forwarder is owned by tlForwarders_ on the publisher exec; clear the registry's ref once that ownership transfers. Callers resolve the forwarder by FullTrackName from the publisher exec rather than holding a registry ref, and duplicate-publisher eviction drains the old forwarder on its own exec (via the displaced same-exec ref or tlForwarders_).


This change is Reviewable

@afrind
afrind force-pushed the feature/lf-subscribe-init-symmetry branch from 9bc3b55 to 3ef013e Compare July 27, 2026 22:34
@afrind
afrind force-pushed the fix/lf-trackstatus-local-forwarder branch from 832a337 to a537cd2 Compare July 27, 2026 22:51

@afrind afrind left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@afrind made 7 comments.
Reviewable status: 0 of 6 files reviewed, 4 unresolved discussions.


src/MoqxRelay.h line 490 at r1 (raw file):

    // Subsequent-subscriber seed (set only when !ownsRelayChain): the live publisher
    // forwarder's largest/extensions, read on the publisher exec.
    std::optional<moxygen::AbsoluteLocation> seedLargest;

I don't like "seed" here


src/MoqxRelay.cpp line 651 at r1 (raw file):

    // Null handle => previous publisher already terminated and onPublishDone() tore it down; skip.
    if (evicted.handle && mode() == Mode::LocalForwarder) {
      // The old forwarder lives on its own exec (registry no longer holds it); unsubscribe and

We don't need comments explaining what we no longer do. Also "its own exec" "its publisher's exec"


src/MoqxRelay.cpp line 660 at r1 (raw file):

            auto oldFwd = displacedLocalFwd;
            if (!oldFwd) {
              auto* localReg = tlForwarders_.get();

Add a one line comment explaining this case in a bit more detail. You can remove "using the displaced ref (same-exec) or tlForwarders_ (cross-exec)." above, in favor of a bit more detail here.


src/MoqxRelay.cpp line 885 at r1 (raw file):

  }
  if (!forwarder) {
    return false;

Does this case warrant an error log?


src/MoqxRelay.cpp line 919 at r1 (raw file):

        publisherExec,
        [pf = std::move(publisherFwd), ex = subscriberExec, re = relayExec]() noexcept {
          // lock on the pub exec: resolves the exact wired forwarder or null if it is gone.

You can add another line to help explain why it can be gone


src/MoqxRelay.cpp line 2163 at r1 (raw file):

  } else {
    // Subsequent subscriber, first on this iothread: seed from the live publisher
    // forwarder so the OK carries the established largest, not this fresh forwarder's

Remove ", not this fresh forwarder's
// unseeded value a client reads as a track restart.
"


src/MoqxRelay.cpp line 2748 at r1 (raw file):

        .sourceAddress = sourceAddr,
    };
    // LF mode clears the registry forwarder (owned by tlForwarders_); stats unavailable here.

FYI - this breaks some components of the /state endpoint that were never really safe in MT mode anyways. We can file an issue to circle back and fix

…istry

In LocalForwarder mode the publisher forwarder is owned by tlForwarders_ on
the publisher exec; clear the registry's ref once that ownership transfers.
Callers resolve the forwarder by FullTrackName from the publisher exec rather
than holding a registry ref, and duplicate-publisher eviction drains the old
forwarder on its own exec (via the displaced same-exec ref or tlForwarders_).
@afrind
afrind force-pushed the fix/lf-trackstatus-local-forwarder branch from a537cd2 to ca3da49 Compare July 27, 2026 23:27
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