-
Notifications
You must be signed in to change notification settings - Fork 15.4k
HOTIFX: fix Kafka Streams upgrade path from 3.4 to 3.5 #14103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -94,6 +94,7 @@ private static boolean upgradeFromV0(final Map<String, ?> configs) { | |||||
| case StreamsConfig.UPGRADE_FROM_31: | ||||||
| case StreamsConfig.UPGRADE_FROM_32: | ||||||
| case StreamsConfig.UPGRADE_FROM_33: | ||||||
| // there is no need to add new versions hers | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| return true; | ||||||
| default: | ||||||
| return false; | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,6 +123,9 @@ public RebalanceProtocol rebalanceProtocol() { | |
| case StreamsConfig.UPGRADE_FROM_31: | ||
| case StreamsConfig.UPGRADE_FROM_32: | ||
| case StreamsConfig.UPGRADE_FROM_33: | ||
| case StreamsConfig.UPGRADE_FROM_34: | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the actual fix. |
||
| // we need to add new version when new "upgrade.from" values become available | ||
|
|
||
| // This config is for explicitly sending FK response to a requested partition | ||
| // and should not affect the rebalance protocol | ||
| break; | ||
|
|
@@ -178,6 +181,9 @@ public int configuredMetadataVersion(final int priorVersion) { | |
| case StreamsConfig.UPGRADE_FROM_31: | ||
| case StreamsConfig.UPGRADE_FROM_32: | ||
| case StreamsConfig.UPGRADE_FROM_33: | ||
| case StreamsConfig.UPGRADE_FROM_34: | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the actual fix. |
||
| // we need to add new version when new "upgrade.from" values become available | ||
|
|
||
| // This config is for explicitly sending FK response to a requested partition | ||
| // and should not affect the metadata version | ||
| break; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,15 +16,34 @@ | |||||||||||||||
| */ | ||||||||||||||||
| package org.apache.kafka.streams.processor.internals.assignment; | ||||||||||||||||
|
|
||||||||||||||||
| import org.apache.kafka.clients.consumer.ConsumerPartitionAssignor; | ||||||||||||||||
| import org.apache.kafka.common.config.ConfigDef; | ||||||||||||||||
| import org.apache.kafka.common.config.ConfigException; | ||||||||||||||||
| import org.apache.kafka.streams.StreamsConfig; | ||||||||||||||||
| import org.junit.Before; | ||||||||||||||||
| import org.junit.Test; | ||||||||||||||||
|
|
||||||||||||||||
| import java.util.HashMap; | ||||||||||||||||
| import java.util.List; | ||||||||||||||||
| import java.util.Map; | ||||||||||||||||
|
|
||||||||||||||||
| import static org.apache.kafka.common.utils.Utils.mkEntry; | ||||||||||||||||
| import static org.apache.kafka.common.utils.Utils.mkMap; | ||||||||||||||||
| import static org.apache.kafka.streams.processor.internals.assignment.AssignmentTestUtils.EMPTY_RACK_AWARE_ASSIGNMENT_TAGS; | ||||||||||||||||
| import static org.hamcrest.MatcherAssert.assertThat; | ||||||||||||||||
| import static org.hamcrest.Matchers.containsString; | ||||||||||||||||
| import static org.junit.Assert.assertThrows; | ||||||||||||||||
| import static org.mockito.Mockito.mock; | ||||||||||||||||
|
|
||||||||||||||||
| public class AssignorConfigurationTest { | ||||||||||||||||
| private final Map<String, Object> config = new HashMap<>(); | ||||||||||||||||
|
|
||||||||||||||||
| @Before | ||||||||||||||||
| public void setup() { | ||||||||||||||||
| config.put(StreamsConfig.APPLICATION_ID_CONFIG, "app.id"); | ||||||||||||||||
| config.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "dummy"); | ||||||||||||||||
| config.put(StreamsConfig.InternalConfig.REFERENCE_CONTAINER_PARTITION_ASSIGNOR, mock(ReferenceContainer.class)); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| @Test | ||||||||||||||||
| public void configsShouldRejectZeroWarmups() { | ||||||||||||||||
|
|
@@ -35,4 +54,52 @@ public void configsShouldRejectZeroWarmups() { | |||||||||||||||
|
|
||||||||||||||||
| assertThat(exception.getMessage(), containsString("Invalid value 0 for configuration max.warmup.replicas")); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| @Test | ||||||||||||||||
| public void rebalanceProtocolShouldSupportAllUpgradeFromVersions() { | ||||||||||||||||
| for (final String upgradeFrom : TestConfig.upgradeFromVersions()) { | ||||||||||||||||
| config.put(StreamsConfig.UPGRADE_FROM_CONFIG, upgradeFrom); | ||||||||||||||||
| final AssignorConfiguration assignorConfiguration = new AssignorConfiguration(config); | ||||||||||||||||
|
|
||||||||||||||||
| // next call should not throw | ||||||||||||||||
| assignorConfiguration.rebalanceProtocol(); | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A more readable option without the need for a comment is:
Suggested change
|
||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| @Test | ||||||||||||||||
| public void configuredMetadataVersionShouldSupportAllUpgradeFromVersions() { | ||||||||||||||||
| for (final String upgradeFrom : TestConfig.upgradeFromVersions()) { | ||||||||||||||||
| config.put(StreamsConfig.UPGRADE_FROM_CONFIG, upgradeFrom); | ||||||||||||||||
| final AssignorConfiguration assignorConfiguration = new AssignorConfiguration(config); | ||||||||||||||||
|
|
||||||||||||||||
| // next call should not throw | ||||||||||||||||
| assignorConfiguration.configuredMetadataVersion(0); | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my previous comment. |
||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| private static class TestValidString extends ConfigDef.ValidString { | ||||||||||||||||
| protected TestValidString(final ConfigDef.ValidString validString) { | ||||||||||||||||
| super(validString); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| List<String> validStrings() { | ||||||||||||||||
| return validStrings; | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| private static class TestConfig extends StreamsConfig { | ||||||||||||||||
| public TestConfig() { | ||||||||||||||||
| super(mkMap( | ||||||||||||||||
| mkEntry(StreamsConfig.APPLICATION_ID_CONFIG, "app.id"), | ||||||||||||||||
| mkEntry(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "dummy") | ||||||||||||||||
| )); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| private static List<String> upgradeFromVersions() { | ||||||||||||||||
| return new TestValidString( | ||||||||||||||||
| (ConfigDef.ValidString) CONFIG.configKeys().get(StreamsConfig.UPGRADE_FROM_CONFIG).validator | ||||||||||||||||
| ).validStrings(); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a fan of "visible for testing". What about the following:
StreamsConfig:Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we just add a constant enum to StreamsConfig and given the hotfix character, I would argue we do not need a KIP for this.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part does not work:
public static final String UPGRADE_FROM_34 = UpgradeFromValues.UPGRADE_FROM_34.toString();We use
and the compiler complain that
StreamsConfig.UPGRADE_FROM_0100must be a constSo not sure if we gain much adding the enum? -- We would still need to remember update the enum, and thus have a "split brain" problem -- getting the List out of the
CONFIGobject seems to be safer.Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a corresponding update, but I am not super happy with it... I believe the original idea to get the list of values from
CONFIGis safer. Curious to hear what others think. In the end I am fine both ways.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use:
Additionally, we can implement a validator that uses the enum to verify the values here:
So we do not need to maintain this list separately from the strings and enums.