Ridzzz0Alam opened a new pull request, #24167:
URL: https://github.com/apache/kafka/pull/24167
### The issue
With `partitioner.availability.timeout.ms` set a broker that has not been
drainable for longer than the timeout should have its partitions excluded from
adaptive partitioning. Only its partitions with queued batches were excluded.
Its empty partitions stayed in and because the partitioner favours short queues
they were among the most likely to be picked. So keyless records went to the
broker that had just been marked unavailable.
### Why it happened
`RecordAccumulator#partitionReady` adds a partition to the load stats before
it checks the deque and an empty deque `continue`s before the availability
check is reached. When an excluded partition gave its slot back with
`--queueSizesIndex` the next empty partition also reused the slot and inherited
its queue size. This dates from KIP-794 (KAFKA-10888).
### The fix
- Check the leader's availability (moved to `isLeaderUnavailable`) before
the partition is added to the load stats so partitions are excluded whether or
not they have batches.
- Slots are no longer given back so an empty partition keeps a queue size of
0.
- No change when `partitioner.availability.timeout.ms` is 0 (the default).
### Tests
- New
`RecordAccumulatorTest#testAdaptiveBuiltInPartitionerExcludesEmptyPartitionsOfUnavailableNode`.
It fails on trunk (a record goes to the empty partition on the unavailable
node) and passes with the fix for both allocation strategies.
- The `producer.internals` tests and `KafkaProducerTest` pass and so do
checkstyle and spotless and spotbugs for `clients`.
### Not covered
- No integration test with a real slow broker. The availability logic only
depends on the node latency stats which the unit test sets directly.
--
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]