You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "josefk31 (via GitHub)" <gi...@apache.org> on 2026/05/11 21:38:11 UTC
Re: [PR] KAFKA-20514: kraft observers should use previous fetch response to decide where to send the next fetch [kafka]
josefk31 commented on code in PR #22111:
URL: https://github.com/apache/kafka/pull/22111#discussion_r3202184412
##########
raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:
##########
@@ -2608,6 +2615,32 @@ private boolean hasConsistentLeader(int epoch, OptionalInt leaderId) {
}
}
+ /**
+ * If the local replica is an observer currently routing fetches to bootstrap servers,
+ * and a non-leader source's fetch response advertises the leader's endpoints, switch
+ * the observer back to fetching from the leader.
+ */
+ private void maybeSwitchObserverFetchToLeader(
Review Comment:
Nit: slightly more descriptive name might be a tad better - for example `maybeSwitchObserverToFetchFromLeader`.
##########
raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:
##########
@@ -2608,6 +2615,32 @@ private boolean hasConsistentLeader(int epoch, OptionalInt leaderId) {
}
}
+ /**
+ * If the local replica is an observer currently routing fetches to bootstrap servers,
+ * and a non-leader source's fetch response advertises the leader's endpoints, switch
+ * the observer back to fetching from the leader.
+ */
+ private void maybeSwitchObserverFetchToLeader(
+ int responseEpoch,
+ OptionalInt responseLeaderId,
+ Endpoints leaderEndpoints,
+ long currentTimeMs
+ ) {
+ if (!hasConsistentLeader(responseEpoch, responseLeaderId)) {
+ throw new IllegalStateException("Received request or response with leader " + responseLeaderId +
Review Comment:
Nit: we might also wish to include `quorum.localIdOrSentinel` in the exception message for convenience.
--
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-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org