Fix sticky handlers executing multiple times with global partitioning#2334
Merged
jeremydmiller merged 1 commit intomainfrom Mar 22, 2026
Merged
Conversation
…#2303) When a message type had both GlobalPartitioned routes (which fan out from companion local queues to sticky handler queues) AND explicit Publish().ToLocalQueue().AddStickyHandler() routes, the message reached each sticky handler via both paths, causing duplicate execution. Defense in depth with three fixes: 1. MessageRouter<T>.DeduplicateRoutes(): When a GlobalPartitionedRoute is present, removes explicit local queue routes targeting sticky handler queues since the fanout already delivers to them. 2. GlobalPartitionedRoute.StickyHandlerFanoutUris: Exposes which local queue URIs the fanout will target, enabling deduplication. 3. FanoutMessageHandler: Deduplicates target URIs with a HashSet to prevent double delivery when the same queue is reachable via multiple paths. Closes #2303 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Mar 22, 2026
This was referenced Mar 29, 2026
This was referenced Apr 5, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #2303
Summary
When a message type was configured with both
GlobalPartitioned()routes and explicitPublish().ToLocalQueue().AddStickyHandler()routes, sticky handlers executed multiple times per message. TheGlobalPartitionedRoutefans out to sticky handler queues via companion local queues, but the explicit local queue routes also delivered to the same queues — causing duplicate execution.Defense in depth with three fixes:
MessageRouter<T>.DeduplicateRoutes()— Primary fix. When aGlobalPartitionedRouteis present, removes explicit local queue routes targeting sticky handler queues since the fanout already delivers to them.GlobalPartitionedRoute.StickyHandlerFanoutUris— Exposes which local queue URIs the fanout targets, enabling deduplication at the router level.FanoutMessageHandler— Safety net. Deduplicates target URIs with aHashSetto prevent double delivery when the same queue is reachable via multiple paths.Reproduction
A Kafka-based test (
sticky_handlers_with_global_partitioning.dual_publish_to_kafka_and_local_sticky_should_not_double_execute) reproduces the exact pattern from the issue:Test plan
🤖 Generated with Claude Code