Skip to content

KAFKA-20514: kraft observers should use previous fetch response to decide where to send the next fetch#22111

Open
kevin-wu24 wants to merge 4 commits intoapache:trunkfrom
kevin-wu24:KAFKA-20514
Open

KAFKA-20514: kraft observers should use previous fetch response to decide where to send the next fetch#22111
kevin-wu24 wants to merge 4 commits intoapache:trunkfrom
kevin-wu24:KAFKA-20514

Conversation

@kevin-wu24
Copy link
Copy Markdown
Contributor

@kevin-wu24 kevin-wu24 commented Apr 21, 2026

Background

Currently, there is a timing issue where a KRaft observer can be stuck fetching from the leader if the next poll occurs after the previous fetch's backoff has completed, and the previous request did not time out. An example of this is if the leader's advertised endpoints are not routable. The bootstrap server endpoints could contain routable endpoints for the leader, but the observer would be stuck fetching from the unroutable endpoints.

Previously, there was an issue where observers could be stuck fetching from the bootstrap servers even if it discovers leader endpoints from the bootstrap fetch. This is because the fetch timeout is not reset on the observer.

What changed

Observer fetching logic should ensure that within the same epoch, all the bootstrap server endpoints and the leader have a chance to serve fetch requests. This logic should be independent of request manager's state.

  • If the fetch timeout has not expired, the observer fetches from the leader
  • If the fetch timeout is expired, the observer fetches from the bootstrap servers
  • If the observer receives a fetch response from bootstrap servers with leader endpoints, the observer resets the fetch timeout

A voter has similar functionality where a fetch timeout expiration and a failed pre-vote election results in a reset of the fetch timer to the same leader in the same epoch.

Testing

Added unit test to KafkaRaftClientFetchTest to show fetches oscillate between the leader and bootstrap endpoints based on the fetch timer.

@github-actions github-actions Bot added triage PRs from the community kraft labels Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kraft triage PRs from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant