sahildevgon commented on code in PR #22453:
URL: https://github.com/apache/kafka/pull/22453#discussion_r4184630870
##########
metadata/src/test/java/org/apache/kafka/controller/ReplicationControlManagerTest.java:
##########
@@ -1203,6 +1203,65 @@ public void testEligibleLeaderReplicas_EffectiveMinIsr()
{
assertEquals(3, replicationControl.getTopicEffectiveMinIsr("foo"));
}
+ // KAFKA-20532: regression tests — getTopicEffectiveMinIsr must tolerate
whitespace-padded
+ // min.insync.replicas values that bypass ConfigDef trimming and are
stored raw.
+ @Test
+ public void testGetTopicEffectiveMinIsr_LeadingWhitespace() {
+ ReplicationControlTestContext ctx = new
ReplicationControlTestContext.Builder().setIsElrEnabled(true).build();
+ ReplicationControlManager replicationControl = ctx.replicationControl;
+ ctx.registerBrokers(0, 1, 2);
+ ctx.unfenceBrokers(0, 1, 2);
+ ctx.createTestTopic("foo", new int[][]{new int[]{0, 1, 2}});
+
+ // Simulate a whitespace-contaminated value reaching the metadata
store (e.g. via ZK
Review Comment:
You're right - ZK mode and the ZK - KRaft migration were removed in 4.0, so
that comment is wrong and I'll drop the ZK reference.▎
The bug is still reachable in 4.x without ZooKeeper.
ControllerConfigurationValidator -> LogConfig.validate() ->
ConfigDef.parseType() trims the value for validation, but
ConfigurationControlManager persists the raw ConfigRecord value
(ConfigurationControlManager.java:346), so a client calling
incrementalAlterConfigs with min.insync.replicas=" 2" passes validation and the
padded string is stored permanently. getTopicEffectiveMinIsr() then reads it
raw and Integer.parseInt(" 2") throws, which the QuorumController treats as an
UnknownServerException and renounces leadership.
Note kafka-configs.sh trims in parseConfigsToBeAdded, so the CLI can't
produce this — it needs a direct AdminClient call. I'll update the test comment
and the JIRA repro accordingly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]