This patch ensures that the leader epoch cache is updated when a broker becomes 
leader with the latest epoch and the log end offset as its starting offset. 
This guarantees that the leader will be able to provide the right truncation 
point even if the follower has data from leader epochs which the leader itself 
does not have. This situation can occur when there are back to back leader 
elections.

Additionally, we have made the following changes:

1. The leader epoch cache enforces monotonically increase epochs and starting 
offsets among its entry. Whenever a new entry is appended which violates 
requirement, we remove the conflicting entries from the cache.
2. Previously we returned an unknown epoch and offset if an epoch is queried 
which comes before the first entry in the cache. Now we return the smallest . 
For example, if the earliest entry in the cache is (epoch=5, startOffset=10), 
then a query for epoch 4 will return (epoch=4, endOffset=10). This ensures that 
followers (and consumers in KIP-320) can always determine where the correct 
starting point is for the active log range on the leader.


### Committer Checklist (excluded from commit message)
- [ ] Verify design and implementation 
- [ ] Verify test coverage and CI build status
- [ ] Verify documentation (including upgrade notes)


[ Full content available at: https://github.com/apache/kafka/pull/5678 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to