ahuang98 commented on code in PR #17807:
URL: https://github.com/apache/kafka/pull/17807#discussion_r1879075672
##########
raft/src/main/java/org/apache/kafka/raft/FollowerState.java:
##########
@@ -202,16 +205,34 @@ public void
setFetchingSnapshot(Optional<RawSnapshotWriter> newSnapshot) {
}
@Override
- public boolean canGrantVote(ReplicaKey candidateKey, boolean
isLogUpToDate) {
+ public boolean canGrantVote(ReplicaKey replicaKey, boolean isLogUpToDate) {
log.debug(
"Rejecting vote request from candidate ({}) since we already have
a leader {} in epoch {}",
- candidateKey,
+ replicaKey,
leaderId,
epoch
);
return false;
}
+ @Override
+ public boolean canGrantPreVote(ReplicaKey replicaKey, boolean
isLogUpToDate) {
+ if (hasFetchedFromLeader) {
+ log.debug(
+ "Rejecting PreVote request from replica ({}) since we already
have a leader {} in epoch {}",
+ replicaKey,
+ leaderId,
+ epoch
+ );
+ return false;
+ } else if (!isLogUpToDate) {
+ log.debug(
+ "Rejecting PreVote request from replica ({}) since replica
epoch/offset is not up to date with us",
+ replicaKey);
+ }
+ return isLogUpToDate;
+ }
Review Comment:
thanks, trying out something a bit wordier to make it clear, lmk what you
think
```
"Rejecting PreVote request from replica ({}) either because we have
already fetched from leader {} " +
"in epoch {} (hasFetchedFromLeader={}), or because the replica's log is
not as up to date with " +
"ours (isLogUpToDate={})",
```
--
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]