You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "chungyichi (via GitHub)" <gi...@apache.org> on 2026/10/24 13:09:42 UTC

[PR] KAFKA-20488 Write the ZK controller epoch to partition state znodes during migration [kafka]

chungyichi opened a new pull request, #23946:
URL: https://github.com/apache/kafka/pull/23946

   ZkTopicMigrationClient wrote state.kraftControllerEpoch() as the
   controller epoch of the partition state znodes in createTopic,
   createTopicPartitions and updateTopicPartitions. The ZK controller
   compares that field with its own controller epoch, so it should be the
   ZK controller epoch, which is what the request-level epoch in the RPCs
   sent by KRaftMigrationDriver already uses.
   
   This patch passes state.zkControllerEpoch() instead and adds a
   regression test that makes the two epochs differ and reads the epoch
   back from the znode after each of the three methods.
   


-- 
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


Re: [PR] KAFKA-20488 Use ZK controller epoch when writing partition state znodes [kafka]

Posted by "chungyichi (via GitHub)" <gi...@apache.org>.
chungyichi commented on code in PR #23946:
URL: https://github.com/apache/kafka/pull/23946#discussion_r4395818433


##########
core/src/test/scala/unit/kafka/zk/migration/ZkMigrationClientTest.scala:
##########
@@ -158,6 +158,52 @@ class ZkMigrationClientTest extends ZkMigrationTestHarness {
     assertEquals(List(1, 2, 3), partition1.isr)
   }
 
+  /**
+   * The controller_epoch stored in a partition state znode is compared against the epoch of the ZK
+   * controller (see KAFKA-20488), so the migration client must write the ZK controller epoch and
+   * not the KRaft controller epoch.
+   */
+  @Test
+  def testPartitionStateUsesZkControllerEpoch(): Unit = {
+    // Claiming the controller bumps the ZK controller epoch from the pre-created 1 to 2, which keeps

Review Comment:
   Thanks, I reworded the comment. ` ZkMigrationTestHarness` sets the ZK controller epoch to 1, and `claimControllerLeadership`  makes it 2.



-- 
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


Re: [PR] KAFKA-20488 Use ZK controller epoch when writing partition state znodes [kafka]

Posted by "chungyichi (via GitHub) via jira" <ji...@kafka.apache.org>.
chungyichi commented on PR #23946:
URL: https://github.com/apache/kafka/pull/23946#issuecomment-6536854902

   CI is red, but I don't think it comes from this change. AclControlManagerTest.testDeleteExceedsMaxRecords ([KAFKA-19513](https://issues.apache.org/jira/browse/KAFKA-19513)) and ConsumerBounceTest.testConsumptionWithBrokerFailures ([KAFKA-15146](https://issues.apache.org/jira/browse/KAFKA-15146)) also fail on recent 3.9 branch builds.
   
   I ran ZkMigrationClientTest and ZkMigrationIntegrationTest locally on JDK 21, and they pass.


-- 
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


Re: [PR] KAFKA-20488 Write the ZK controller epoch to partition state znodes during migration [kafka]

Posted by "chungyichi (via GitHub)" <gi...@apache.org>.
chungyichi commented on PR #23946:
URL: https://github.com/apache/kafka/pull/23946#issuecomment-6384608623

   Testing:
   - New `ZkMigrationClientTest#testPartitionStateUsesZkControllerEpoch`. The
     harness uses KRaft epoch 42 and ZK epoch 1; the test first claims
     controller leadership so the ZK epoch becomes 2, then asserts that the
     partition state znode's controllerEpoch equals the ZK epoch after
     createTopic, updateTopicPartitions and createTopicPartitions. Without the
     fix it fails with `expected: <2> but was: <42>`.
   - Ran in a JDK 17 container: `kafka.zk.migration.*` and `kafka.zk.ZkMigration*`
     (57 tests) pass, plus `:core:checkstyleMain`, `:core:checkstyleTest` and
     `:core:spotlessCheck`. I have not run the full `:core:test` suite.
   
   Notes:
   - Znodes already written with the KRaft epoch by an unpatched controller are
     not repaired by this change; they keep that value until the partition state
     is written again.
   - This targets 3.9 because ZooKeeper and the migration code were removed in 4.0.
   


-- 
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


Re: [PR] KAFKA-20488 Use ZK controller epoch when writing partition state znodes [kafka]

Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #23946:
URL: https://github.com/apache/kafka/pull/23946#discussion_r4380246937


##########
core/src/test/scala/unit/kafka/zk/migration/ZkMigrationClientTest.scala:
##########
@@ -158,6 +158,52 @@ class ZkMigrationClientTest extends ZkMigrationTestHarness {
     assertEquals(List(1, 2, 3), partition1.isr)
   }
 
+  /**
+   * The controller_epoch stored in a partition state znode is compared against the epoch of the ZK
+   * controller (see KAFKA-20488), so the migration client must write the ZK controller epoch and
+   * not the KRaft controller epoch.
+   */
+  @Test
+  def testPartitionStateUsesZkControllerEpoch(): Unit = {
+    // Claiming the controller bumps the ZK controller epoch from the pre-created 1 to 2, which keeps

Review Comment:
   What does `pre-created 1 to 2` mean?



-- 
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


Re: [PR] KAFKA-20488 Use ZK controller epoch when writing partition state znodes [kafka]

Posted by "chia7712 (via GitHub) via jira" <ji...@kafka.apache.org>.
chia7712 merged PR #23946:
URL: https://github.com/apache/kafka/pull/23946


-- 
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