You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "jsancio (via GitHub)" <gi...@apache.org> on 2023/06/27 14:42:19 UTC

[GitHub] [kafka] jsancio commented on a diff in pull request #13910: KAFKA-15109 Ensure the leader epoch bump occurs for older MetadataVersions

jsancio commented on code in PR #13910:
URL: https://github.com/apache/kafka/pull/13910#discussion_r1243870229


##########
metadata/src/test/java/org/apache/kafka/controller/PartitionChangeBuilderTest.java:
##########
@@ -207,7 +211,7 @@ public void testTriggerLeaderEpochBumpIfNeeded() {
             createFooBuilder()
                 .setTargetIsrWithBrokerStates(
                     AlterPartitionRequest.newIsrToSimpleNewIsrWithBrokerEpochs(Arrays.asList(2, 1, 3, 4)))
-                .setBumpLeaderEpochOnIsrShrink(true),
+                .enableBumpLeaderEpochOnIsrShrink(true),

Review Comment:
   Got it. Outside the scope of this PR but it looks like we are missing some validation. This is adding 4 to the ISR but 4 is not a replica for this partition. cc @ahuang98 



##########
metadata/src/main/java/org/apache/kafka/controller/PartitionChangeBuilder.java:
##########
@@ -300,9 +288,13 @@ private void tryElection(PartitionChangeRecord record) {
      */
     void triggerLeaderEpochBumpIfNeeded(PartitionChangeRecord record) {
         if (record.leader() == NO_LEADER_CHANGE) {
+            boolean bumpLeaderEpochOnIsrShrink = metadataVersion.isLeaderEpochBumpRequiredOnIsrShrink() || zkMigrationEnabled;
+
             if (!Replicas.contains(targetReplicas, partition.replicas)) {
+                // Reassignment
                 record.setLeader(partition.leader);
-            } else if (bumpLeaderEpochOnIsrShrink && !Replicas.contains(targetIsr, partition.isr)) {
+            } else if (!Replicas.contains(targetIsr, partition.isr) && bumpLeaderEpochOnIsrShrink) {

Review Comment:
   We should check `bumpLeaderEpochOnIsrShrink` first as it is faster to compute. It avoids a search through the ISR arrays when it is false (most cases after MV 3.6).



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org