anjy7 opened a new pull request, #23118:
URL: https://github.com/apache/kafka/pull/23118
## Problem
When a `KafkaRaftClient` leader stops being the leader, its parked requests
can no longer complete normally: pending appends can't gather the
acknowledgments to commit at the old epoch, and held fetches should be failed
so callers retry against the new leader. Both purgatories should therefore be
completed exceptionally on any leader → non-leader transition. Only
`onBecomeFollower` did this; the other two leader-exit paths did not.
So a leader that resigns, or drops to unattached (e.g. on seeing a higher
epoch with no known leader), left pending appends. And, for unattached, pending
fetches, sitting in purgatory until their request timeout expired.
## Impact
The parked futures eventually expire via `request.timeout.ms`. But until
then, callers wait the full timeout for a failure that is already certain, and
each pending append future keeps its `CompletedBatch` (and backing
`ByteBuffer`) pinned in memory for that duration.
## Testing
- `testResignWillCompleteAppendPurgatory` and
`testTransitionToUnattachedWillCompleteAppendPurgatory`
(new): park an uncommitted append and assert the append purgatory goes
from non-empty to empty
across the transition (via a new test-only `appendPurgatoryNumWaiting()`
accessor).
- `testTransitionToUnattachedWillCompleteFetchPurgatory` (new): asserts a
held fetch is completed
with `NOT_LEADER_OR_FOLLOWER` on the unattached path (mirrors the existing
`testResignWillCompleteFetchPurgatory`).
--
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]