Fix concurrency exceptions with global partitioned Kafka topics#2344
Merged
jeremydmiller merged 2 commits intomainfrom Mar 24, 2026
Merged
Fix concurrency exceptions with global partitioned Kafka topics#2344jeremydmiller merged 2 commits intomainfrom
jeremydmiller merged 2 commits intomainfrom
Conversation
Three root causes were identified and fixed: 1. Shared Kafka consumer GroupId: When using UseShardedKafkaTopics for global partitioning, each node used its own ServiceName as the Kafka consumer GroupId. This caused all nodes to receive all messages (broadcast) instead of exclusive partition assignment. Fixed by setting a deterministic GroupId based on the baseName in PartitionedMessageTopologyWithTopics.buildListener. 2. Consumer GroupId overwriting business GroupId: The Kafka listener stamped the consumer group name onto Envelope.GroupId, overwriting the business partition key (e.g. aggregate ID) set by ByPropertyNamed. This broke the local queue sharding since all messages got the same GroupId hash. Fixed by calling DisableConsumerGroupIdStamping on sharded topic listeners. 3. GlobalPartitionedReceiverBridge not handled in EnqueueDirectlyAsync: When the durability agent reassigned messages, ListeningAgent threw "no active local queue" because GlobalPartitionedReceiverBridge was not recognized as a valid receiver type. Fixed by adding a case for the bridge in ListeningAgent.EnqueueDirectlyAsync. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The concurrency test spins up 3 in-process hosts with Kafka and Marten, which is resource-intensive and can cause OOM aborts in the Kafka test suite. Move it to SlowTests where long-running tests belong. Added Wolverine.Kafka project reference to SlowTests.csproj. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Mar 25, 2026
This was referenced Apr 2, 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.
Summary
Fixes concurrency exceptions (
EventStreamUnexpectedMaxEventIdException) when usingUseShardedKafkaTopicsfor global partitioned messaging across multiple nodes.Three root causes were identified and fixed:
Shared Kafka consumer GroupId: Each node used its own
ServiceNameas the Kafka consumer GroupId, causing all nodes to receive all messages (broadcast) instead of exclusive partition assignment. Fixed by setting a deterministic GroupId based on thebaseNameinPartitionedMessageTopologyWithTopics.buildListener.Consumer GroupId overwriting business GroupId: The Kafka listener stamped the consumer group name onto
Envelope.GroupId, overwriting the business partition key (e.g. aggregate ID) set byByPropertyNamed. This broke local queue sharding since all messages got the same GroupId hash. Fixed by callingDisableConsumerGroupIdStamping()on sharded topic listeners.GlobalPartitionedReceiverBridgenot handled inEnqueueDirectlyAsync: When the durability agent reassigned messages,ListeningAgentthrew "no active local queue" becauseGlobalPartitionedReceiverBridgewas not recognized as a valid receiver type. Fixed by adding a case for the bridge.Test plan
Bug_concurrency_with_global_partitioningtest passes (0 exceptions, 0 duplicate envelope executions across 3 hosts over 30 seconds)🤖 Generated with Claude Code