showuon commented on code in PR #15732: URL: https://github.com/apache/kafka/pull/15732#discussion_r1571963909
########## metadata/src/main/java/org/apache/kafka/metadata/migration/KRaftMigrationDriver.java: ########## @@ -786,12 +773,29 @@ public void run() throws Exception { } } + class RecoverMigrationStateFromZKEvent extends MigrationEvent { + @Override + public void run() throws Exception { + applyMigrationOperation("Recovering migration state from ZK", zkMigrationClient::getOrCreateMigrationRecoveryState); + String maybeDone = migrationLeadershipState.initialZkMigrationComplete() ? "done" : "not done"; + log.info("Initial migration of ZK metadata is {}.", maybeDone); + + // Once we've recovered the migration state from ZK, install this class as a metadata publisher + // by calling the initialZkLoadHandler. + initialZkLoadHandler.accept(KRaftMigrationDriver.this); + + // Transition to INACTIVE state and wait for leadership events. + transitionTo(MigrationDriverState.INACTIVE); + } + } + class PollEvent extends MigrationEvent { + @Override public void run() throws Exception { switch (migrationState) { case UNINITIALIZED: - recoverMigrationStateFromZK(); + eventQueue.append(new RecoverMigrationStateFromZKEvent()); Review Comment: No need. Like I said in this [comment](https://github.com/apache/kafka/pull/15732#discussion_r1570596642), in the `UNINITIALIZED` state, the only event we will receive is the `pollEvent`. We'll receive additional`onControllerChange` (`KRaftLeaderEvent`) and `onMetadataUpdate` (`MetadataChangeEvent`) after completing `RecoverMigrationStateFromZKEvent`. So, we don't have to worry about the order at this moment. -- 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-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org