soarez commented on code in PR #15732: URL: https://github.com/apache/kafka/pull/15732#discussion_r1572550218
########## 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: Are we allowing a race between the `RecoverMigrationStateFromZKEvent` and the next `PollEvent` scheduled after the switch? Maybe this could be more straightforward if we only schedule the next poll once `RecoverMigrationStateFromZKEvent` finishes, either normally or exceptionally? WDYT? -- 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