fix(consumer): store original topic names for partition reconnection#388
Open
jr011 wants to merge 1 commit intostreamnative:masterfrom
Open
fix(consumer): store original topic names for partition reconnection#388jr011 wants to merge 1 commit intostreamnative:masterfrom
jr011 wants to merge 1 commit intostreamnative:masterfrom
Conversation
When using explicit topic subscription, MultiTopicConsumer failed to reconnect to partitions after broker failures because the topics field stored expanded partition names instead of original topic names. This change ensures that: - topics field stores original topic names (e.g., 'my-topic') - existing_topics field stores expanded partition names - update_topics() can correctly re-lookup and reconnect to partitions Fixes partition reconnection issue in production environments.
Contributor
BewareMyPower
left a comment
There was a problem hiding this comment.
Could you add a test?
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.
Fix: MultiTopicConsumer Cannot Discover New Partitions After Topic Expansion
Problem Description
When subscribing to partitioned topics using
with_topic(),MultiTopicConsumerfails to discover and connect to new partitions added during runtime partition expansion.Symptoms
created 0 consumersinstead of creating consumers for new partitionsRoot Cause
In
src/consumer/builder.rs(lines 288-289), thetopicsfield was incorrectly initialized with expanded partition names instead of original topic names:Before:
This causes two issues:
Cannot discover new partitions: When
update_topics()queries using partition names like"test-partition-0", the service discovery detects-partition-suffix and short-circuits returning 0, preventing partition re-expansion.Consumer lookup fails: If
existing_topicscontains original names whileconsumersmap uses partition names,poll_next()cannot find consumers.Solution
Store original topic names in
topicsand expanded partition names inexisting_topics:After (lines 290-296):
Field Purposes
topicsupdate_topics()to re-query partition count["test"]existing_topicspoll_next()to poll consumers["test-partition-0", "test-partition-1", ...]Files Changed
src/consumer/builder.rs(lines 290-296)Related Files
src/consumer/multi.rs(lines 144-200) -update_topics()methodsrc/consumer/multi.rs(lines 362-390) -poll_next()methodsrc/service_discovery.rs(lines 175-264) - partition lookup logic