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
KAFKA-14405: Log a warning when users attempt to set a config controlled by Streams #12988
base: trunk
Are you sure you want to change the base?
Conversation
Since I am fairly new to the code base - I will be spending some more time identifying any other configs that I might have missed that can fall under any of these buckets. |
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.
Thanks for the PR! One config in particular that is kind of a special case is the ProducerConfig default.partitioner
It's not that Streams overrides this (as is the case for other configs, like allow.auto.create.topics) but you just can't use it within Streams without breaking your app. We have a special StreamsPartitioner
interface for Streams users to plug in rather than using this config.
I guess rather than adding special handling, we could just add it to the PRODUCER_DEFAULT_OVERRIDES
similar to what you did here already, and just override it to null
Hi @ableegoldman thank you for the review! |
Ah, yeah, sorry -- it's |
What's the status of this PR? |
This PR is being marked as stale since it has not had any activity in 90 days. If you would like to keep this PR alive, please ask a committer for review. If the PR has merge conflicts, please update it with the latest from trunk (or appropriate release branch) If this PR is no longer valid or desired, please feel free to close it. If no activity occurrs in the next 30 days, it will be automatically closed. |
Will be re-picking this. My bad for dropping this in the middle. |
Thanks! Great to hear. |
Hi @mjsax, a small doubt - If a user has set the property Is this expected behaviour? |
Sorry for late reply. I was OOO. Well, if it can be by-passed, it sounds like a bug. Because there are multiple consumer, we use But no matter what prefix is used, we should not allow users to by-pass what Streams tries to overwrite. (Btw: just setting |
Got it @mjsax - It's within the private Map<String, Object> getCommonConsumerConfigs() {
// Fetch all consumer props starting with "consumer."
clientProvidedProps = getClientPropsWithPrefix(CONSUMER_PREFIX, ConsumerConfig.configNames());
// CLean out any properties that were set but need to be controlled by streams
checkIfUnexpectedUserSpecifiedConfig(clientProvidedProps, NON_CONFIGURABLE_CONSUMER_DEFAULT_CONFIGS);
checkIfUnexpectedUserSpecifiedConfig(clientProvidedProps, NON_CONFIGURABLE_CONSUMER_EOS_CONFIGS);
// Create a config map of the preferred props and merge it with the cleaned props from above
final consumerProps =new (eosEnabled ? CONSUMER_EOS_OVERRIDES : CONSUMER_DEFAULT_OVERRIDES);
consumerProps.putAll(clientProvidedProps);
} And the logic within public Map<String, Object> getMainConsumerConfigs(...) {
// Fetch the props starting with "consumer." after cleaning
// any props that needed to be overwritten
final consumerProps = getCommonConsumerConfigs();
// Get main consumer override props i.e. the ones
// starting with "main.consumer." and merge the two maps.
final mainConsumerProps = originalsWithPrefix(MAIN_CONSUMER_PREFIX);
for (final entry: mainConsumerProps.entrySet()) {
consumerProps.put(entry.getKey(), entry.getValue());
// Continue processing and filling in other required configs
} Do you think I've understood this piece correct? |
Thanks for digging into this -- I think you are spot on -- seem we should extract a method that will set KS controlled config, and refactor I assume we need to do something similar for restore and global consumer? -- To be fair, I was actually aware that something is off and still have a (old and stale) local branch adding corresponding testing to |
Got it! I'll make this change - for now I have gone through the code and the following two references and compiled a list of configs that are somehow "controlled" by KS. For now sharing the Producer Configs here and soon Consumer Configs too Producer Configs with EoS Disabled
Producer Configs with EoS Disabled
|
@ashmeet13 -- Any update on this PR? We are coming up to 3.7 release code freeze deadline. Might be nice to finish this on time? |
Hi @mjsax apologies for the delay. Pushing this soon. |
@ashmeet13 -- do you still have interest to finish this PR? |
@@ -1140,6 +1145,7 @@ public class StreamsConfig extends AbstractConfig { | |||
static { | |||
final Map<String, Object> tempProducerDefaultOverrides = new HashMap<>(); | |||
tempProducerDefaultOverrides.put(ProducerConfig.LINGER_MS_CONFIG, "100"); | |||
tempProducerDefaultOverrides.put(ProducerConfig.PARTITIONER_CLASS_CONFIG, "none"); |
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.
Default is already null
-- why do we need to set it?
@@ -1883,3 +1886,20 @@ public static void main(final String[] args) { | |||
System.out.println(CONFIG.toHtml(4, config -> "streamsconfigs_" + config)); | |||
} | |||
} | |||
|
|||
|
|||
public Map<String, Object> getMainConsumerConfigs(...) { |
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.
StreamsConfig
is public API and we cannot just modify it w/o a KIP. -- Also, why do we need this new method to begin with? We already have getMainConsumerConfigs(...)
.
@@ -530,6 +530,14 @@ public void shouldSetInternalLeaveGroupOnCloseConfigToFalseInConsumer() { | |||
assertThat(consumerConfigs.get("internal.leave.group.on.close"), is(false)); | |||
} | |||
|
|||
@Test | |||
public void shouldResetToDefaultIfConsumerAllowAutoCreateTopicsIsOverridden() { |
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 should apply to all consumers, right? Should we extend the test accordingly?
Should we also capture the logs and verify that the WARN is printed (not sure if necessary)?
@ashmeet13 -- any updates on this PR? |
Streams hard-codes a few configurations, currently the documentation refers to 5 such configs.
The four mentioned within - Parameters controlled by Kafka Streams + enable.auto.commit.
Three out of the 4 mentioned within the Parameters controlled by Kafka Streams are also present within Default Values which state the configurations that can be configured but will have a default value if not set.
This PR makes changes to warn the user when a configuration set by them is being overridden.
Due to the overlapping documentation I have gone through the code and have separated the configs in a few categories -
StreamsConfig
already had code to log warnings when a non-configurable property was being set.It was missing logging warnings when
allow.auto.create.topics
was configured. I have added this change and removed the code that was settingallow.auto.create.topics
withingetMainConsumerConfigs
.Now it follows the existing code execution path to check for -
Permalink to checkIfUnexpectedUserSpecifiedConsumerConfig
Committer Checklist (excluded from commit message)