jsancio commented on code in PR #22620:
URL: https://github.com/apache/kafka/pull/22620#discussion_r3786197312
##########
raft/src/main/java/org/apache/kafka/raft/internals/UpdateVoterHandler.java:
##########
@@ -219,56 +424,116 @@ private Optional<VoterSet> updateVoters(
voters.updateVoterIgnoringDirectoryId(updatedVoter);
}
- private CompletionStage<UpdateRaftVoterResponseData> storeUpdatedVoters(
+ private void storeUpdatedVoters(
LeaderState<?> leaderState,
- ReplicaKey voterKey,
+ UpdateVoterHandlerState current,
Optional<KRaftVersionUpgrade.Voters> inMemoryVoters,
VoterSet newVoters,
- ListenerName requestListenerName,
long currentTimeMs
) {
+ var changeVoterState = leaderState.changeVoterState();
+
if (inMemoryVoters.isEmpty()) {
- // Since the partition support reconfig then just write the update
voter set directly to the log
- leaderState.appendVotersRecord(newVoters, currentTimeMs);
+ /* Since the partition supports reconfig, write the updated voter
set directly to the log.
+ *
+ * Complete the RPC but don't reset the handler state. This allows
the follower to send a FETCH
+ * request and help to commit the voter set change.
+ */
+ current.setLastOffset(leaderState.appendVotersRecord(newVoters,
currentTimeMs));
+ current.completeFuture(
+ RaftUtil.updateVoterResponse(
+ Errors.NONE,
+ current.requestListenerName(),
+ leaderState.leaderAndEpoch(),
+ leaderState.leaderEndpoints()
+ )
+ );
} else {
// Store the new voters set in the leader state since it cannot be
written to the log
var successful = leaderState.compareAndSetVolatileVoters(
inMemoryVoters.get(),
new KRaftVersionUpgrade.Voters(newVoters)
);
if (successful) {
- log.info(
+ logger.info(
"Updated in-memory voters from {} to {}",
inMemoryVoters.get().voters(),
newVoters
);
+
+ // Reset the check quorum state since the leader received a
successful request
+
leaderState.updateCheckQuorumForFollowingVoter(current.voterKey(),
currentTimeMs);
Review Comment:
Thanks for catching this. I fixed it and added a test for it.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]