jsancio commented on code in PR #19416: URL: https://github.com/apache/kafka/pull/19416#discussion_r2050842542
########## raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java: ########## @@ -3192,13 +3223,36 @@ private long pollFollowerAsVoter(FollowerState state, long currentTimeMs) { transitionToProspective(currentTimeMs); backoffMs = 0; } else if (state.hasUpdateVoterPeriodExpired(currentTimeMs)) { + final boolean resetUpdateVoterTimer; if (partitionState.lastKraftVersion().isReconfigSupported() && - partitionState.lastVoterSet().voterNodeNeedsUpdate(quorum.localVoterNodeOrThrow())) { - backoffMs = maybeSendUpdateVoterRequest(state, currentTimeMs); + partitionState.lastVoterSet().voterNodeNeedsUpdate(quorum.localVoterNodeOrThrow()) + ) { + // When the cluster supports reconfiguration, send an updated voter configuration + // if the one in the log doesn't match the local configuration. + var sendResult = maybeSendUpdateVoterRequest(state, currentTimeMs); + // Update the request timer if the request was sent + resetUpdateVoterTimer = sendResult.first(); + backoffMs = sendResult.second(); + } else if (!partitionState.lastKraftVersion().isReconfigSupported() && + !state.hasUpdatedLeader() + ) { + // When the cluster doesn't support reconfiguration, the voter needs to send its + // voter information to every new leader. This is because leaders don't persist voter + // information when reconfiguration has not been enabled. The updated voter information + // is required to be able to upgrade the cluster from kraft.version 0. + var sendResult = maybeSendUpdateVoterRequest(state, currentTimeMs); + // Update the request timer if the request was sent + resetUpdateVoterTimer = sendResult.first(); + backoffMs = sendResult.second(); Review Comment: Yes. Added a predicate to simplify this code. -- 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