KAFKA-20464: Fix topology corruption when ConnectedStoreProviders share a StoreBuilder#22102
Open
ChoMinGi wants to merge 1 commit intoapache:trunkfrom
Open
Conversation
Comment on lines
+714
to
+727
| @Test | ||
| public void shouldUniteProcessorsWhenAddStateStoreCalledMultipleTimesWithSameBuilder() { | ||
| final StoreBuilder<?> sharedStore = new MockKeyValueStoreBuilder("shared-store", false); | ||
|
|
||
| builder.addSource(null, "source-1", null, null, null, "topic-1"); | ||
| builder.addProcessor("processor-1", new MockApiProcessorSupplier<>(), "source-1"); | ||
| builder.addStateStore(sharedStore, "processor-1"); | ||
|
|
||
| builder.addSource(null, "source-2", null, null, null, "topic-2"); | ||
| builder.addProcessor("processor-2", new MockApiProcessorSupplier<>(), "source-2"); | ||
| builder.addStateStore(sharedStore, "processor-2"); | ||
|
|
||
| assertEquals(1, builder.describe().subtopologies().size()); | ||
| } |
Contributor
There was a problem hiding this comment.
We already have very similar test: shouldAllowAddingSameStoreBuilderMultipleTimes
This one imo is better because it uses addStateStore api
I think we can remove shouldAllowAddingSameStoreBuilderMultipleTimes in favor of this one
Contributor
Author
There was a problem hiding this comment.
@UladzislauBlok
Removed, thanks for catching that :)
…re a StoreBuilder
70d1794 to
ae85398
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 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.
KAFKA-20464
ConnectedStoreProviderJavadoc documents that multiple providers may return the sameStoreBuilderinstance to share a store. Currently this places the processors in separate subtopologies becauseaddStateStore()overwrites thestateFactoriesentry, losing the previousconnectedProcessorNames.The fix is a one-line conditional: skip the put when a compatible factory already exists. Tests added in
StreamsBuilderTestandInternalTopologyBuilderTest.On upgrade, affected topologies will see subtopology regrouping — task IDs from the previously separate subtopology will no longer exist, and their state will be restored from changelog topics on first restart.