lucliu1108 opened a new pull request, #24376: URL: https://github.com/apache/kafka/pull/24376
The javadoc of `RebalanceListener#onPartitionsLost` says `position()` and `seek()` fail on lost partitions, but the lost partitions are still in the assignment while the callback runs, so both can be used. This PR fixes the javadoc and adds integration tests for the documented behavior. ### Javadoc changes: -`position()` and `seek()` can be used on lost partitions. With the Consumer protocol, `position()` on a lost partition that has no position yet times out, because the partition is marked pending revocation before the callback and is never initialized. Calling `seek()` first avoids this. - Commits are rejected because the consumer is no longer an active member of the group. With the Classic protocol they are rejected on the client. With the Consumer protocol they are rejected by the broker, unless no other members remain in the group, in which case the commit succeeds. ### Tests - testClassicConsumerAwareSeekAndPositionOnPartitionsLost: Classic. `tp` is still in `assignment()`, and after `seek(tp, 3)`, `position(tp)` returns 3. - testAsyncConsumerAwareSeekAndPositionOnPartitionsLost: Consumer protocol, same as above. - testAsyncConsumerAwarePositionWithoutInitialPositionOnPartitionsLost: Consumer protocol. `tp` has no position yet, and `position(tp, 1s)` throws `TimeoutException`. - testClassicConsumerAwarePositionOnPartitionsLost: Classic. `tp` already has a position, and `position(tp)` returns 0 without `seek()`. - testAsyncConsumerAwarePositionOnPartitionsLost: Consumer protocol, same as above. - testClassicConsumerAwareCommitOnPartitionsLost: Classic. `commitSync()` and `commitSync(offsets)` throw `CommitFailedException`. - testAsyncConsumerAwareCommitOnPartitionsLostWithOtherMembers: Consumer protocol with another member in the group. `commitSync()` and `commitSync(offsets)` throw `CommitFailedException`. - testAsyncConsumerAwareCommitOnPartitionsLostWithoutOtherMembers: Consumer protocol with no other members. `commitSync(tp -> 3)` succeeds and the committed offset is 3. - testClassicConsumerAwareCommitAsyncOnPartitionsLost: Classic. The callbacks of `commitAsync(callback)` and `commitAsync(offsets, callback)` receive `CommitFailedException`. - testAsyncConsumerAwareCommitAsyncOnPartitionsLostWithOtherMembers: Consumer protocol with another member in the group. The callbacks of `commitAsync(callback)` and `commitAsync(offsets, callback)` receive `CommitFailedException`. -- 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]
