Skip to content

Commit

Permalink
kafka/s: Reject leader epoch requests in future
Browse files Browse the repository at this point in the history
- If the user attempts to make a offset_for_leader_epoch request where
the requested epoch is ahead of the latest known, the response should
contain -1s for requested epoch and end_offset.

- Fixes: redpanda-data#11864
  • Loading branch information
graphcareful committed Jul 12, 2023
1 parent a8d78ad commit d7184ee
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/v/kafka/server/replicated_partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@ replicated_partition::get_leader_epoch_last_offset_unbounded(
const model::term_id term(epoch);
const auto first_local_offset = _partition->raft_start_offset();
const auto first_local_term = _partition->get_term(first_local_offset);
const auto last_local_term = _partition->term();
if (term > last_local_term) {
// Request for term that is in the future
co_return std::nullopt;
}
// Look for the highest offset in the requested term, or the first offset
// in the next term. This mirrors behavior in Kafka, see
// https://github.com/apache/kafka/blob/97105a8e5812135515f5a0fa4d5ff554d80df2fe/storage/src/main/java/org/apache/kafka/storage/internals/epoch/LeaderEpochFileCache.java#L255-L281
Expand Down

0 comments on commit d7184ee

Please sign in to comment.