Repository navigation
fix(streaming): remove defunct stream publishers - #10532
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses duplicate stream publishers in the pub/sub registry after cluster restarts by removing defunct system-target publishers (e.g., persistent stream pulling agents) before registering a replacement producer, plus adding a regression test to validate the behavior.
Changes:
- Inject
IClusterMembershipServiceintoPubSubRendezvousGrainand remove terminating/dead system-target producers prior toRegisterProducer. - Add a regression test which registers a producer from a predecessor silo generation and verifies that registering the replacement leaves a single producer.
Show a summary per file
| File | Description |
|---|---|
src/Orleans.Streaming/PubSub/PubSubRendezvousGrain.cs |
Removes terminating/dead system-target producers before registering a new producer to prevent duplicate persisted publishers after restarts. |
test/Orleans.Streaming.Tests/StreamingTests/PubSubRendezvousGrainTests.cs |
Adds a regression test ensuring a replacement pulling agent registration results in exactly one publisher. |
Review details
Tip
Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
This was referenced Aug 12, 2026
Contributor
There was a problem hiding this comment.
Review details
Suppressed comments (1)
src/Orleans.Streaming/PubSub/PubSubRendezvousGrain.cs:134
RegisterProducernow callsRemoveDefunctSystemTargetProducers()for every producer registration. That method scans all existing producers and can trigger a membership-source refresh, which adds avoidable overhead for normal (non-pulling-agent) producers. Since the duplicate-publisher scenario is specific to stream pulling agents (system targets), consider gating this cleanup to only run when the registering producer is a pulling agent system target.
await RemoveDefunctSystemTargetProducers();
- Files reviewed: 11/11 changed files
- Comments generated: 0 new
- Review effort level: Lite
ReubenBond
force-pushed
the
rb-fix-sms-stream-restart
branch
from
August 13, 2026 18:57
ebfc123 to
d74e302
Compare
Contributor
There was a problem hiding this comment.
Review details
Suppressed comments (1)
test/Orleans.Streaming.Tests/StreamingTests/PubSubRendezvousGrainTests.cs:131
replacementProduceris built usingrendezvousSilo, which doesn’t exercise the restart/replacement identity scenario the test name describes. To validate that a producer from the restarted silo’s new address replaces the persisted producer from the old generation, create the replacement producer usingreplacementSilo.SiloAddressinstead.
var replacementProducer = SystemTargetGrainId.Create(
Constants.StreamPullingAgentType,
rendezvousSilo,
"ProviderName_1_test-queue").GrainId;
- Files reviewed: 11/11 changed files
- Comments generated: 0 new
- Review effort level: Lite
ReubenBond
force-pushed
the
rb-fix-sms-stream-restart
branch
from
August 15, 2026 09:12
d74e302 to
1935a04
Compare
Add an explicit IMembershipManager source-freshness operation instead of overloading Refresh semantics. Table-based membership guarantees progress with an independent full read, while implementations may also satisfy the fence using writes which publish complete views. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 1abf096e-7d27-435b-9339-a78329f6fb12
Fold source freshness fencing into IMembershipManager.Refresh using an explicit requireFresh option while preserving existing coalesced refresh behavior by default. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 1abf096e-7d27-435b-9339-a78329f6fb12
Prevent delayed pulling-agent registrations from recreating stale pub/sub entries after a replacement publisher has registered. Reject the registration with a retryable failure so transient membership convergence cannot silently drop an active publisher. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 8f04121e-7bad-4fe4-9746-4856285ebca8
Co-authored-by: Copilot App <[email protected]>
Reject incoming system-target publishers when membership validation is indeterminate so a failed source refresh cannot recreate a stale publisher. Existing unknown publishers remain retained until their status can be confirmed. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 8f04121e-7bad-4fe4-9746-4856285ebca8
Make distinct silo addresses an input invariant and propagate cancellation through the fresh membership refresh. Co-authored-by: Copilot App <[email protected]> Copilot-Session: b80076ce-da56-4d4f-8419-e30849633d6e
Flow the registering silo's observed membership version through an additive pub/sub RPC and persisted publisher state so causally newer membership snapshots reject defunct publishers. Treat the default membership version as legacy state during rolling upgrades. Co-authored-by: Copilot App <[email protected]> Copilot-Session: b80076ce-da56-4d4f-8419-e30849633d6e
Make the default membership version's persisted-state compatibility role explicit and align registration rejection diagnostics with runtime behavior. Co-authored-by: Copilot App <[email protected]> Copilot-Session: b80076ce-da56-4d4f-8419-e30849633d6e
Co-authored-by: Copilot App <[email protected]> Copilot-Session: b80076ce-da56-4d4f-8419-e30849633d6e
ReubenBond
force-pushed
the
rb-fix-sms-stream-restart
branch
from
September 13, 2026 15:05
bcc3236 to
c3fcfd3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Persistent stream pulling agents are system targets whose identities include their silo address and generation. Pub/sub state survives a cluster restart, while shutdown-time publisher unregistration is best-effort. When unregistration races silo teardown, the persisted publisher remains and the replacement pulling agent registers under a new identity, producing the duplicate publisher observed in #10503, #10702, #10822, and #11033.
Producer registration now validates persisted system-target publishers against cluster membership before adding the replacement. Publishers on terminating or dead silo generations are removed and the updated rendezvous state is persisted before removal metrics are emitted. Ordinary producers retain their existing registration path.
Legacy and future-version participants require a fresh source-of-truth membership observation. Each refresh operation retains the newest status observed for its participating silo generations, so correctness is independent of bounded-cache eviction and an older refresh cannot overwrite a newer dead classification. Registrations carry the membership version which observed the producer silo, and stale registrations are rejected so an old pulling agent cannot restore itself after cleanup.
Recreated membership storage can reuse a version recorded in durable pub/sub state. Absent publishers at that equal-version boundary also receive fresh source-of-truth validation. This resolves the previous silo generation and allows the healthy replacement to register even when its endpoint changes and cluster membership remains stable.
Legacy persisted publisher state retains its default membership-version sentinel. Pinned RPC aliases preserve rolling compatibility for the expanded cancellable
RegisterProducercontract across generated callers and targets.Fixes #10503
Fixes #10702
Fixes #10822
Fixes #11033