[fix][client] Fix unAckedMessageTracker cleanup on multi-topics batch ack
Motivation
This fixes a bug in MultiTopicsConsumerImpl.doAcknowledge(List<MessageId>, ...).
When batch acknowledging messages across multiple topics, the success callback used
messageIdList.forEach(unAckedMessageTracker::remove) instead of
messageIds.forEach(unAckedMessageTracker::remove). As a result, after one underlying
consumer ack succeeded, all messages in the batch were removed from
unAckedMessageTracker, including messages that had not yet been acked by other consumers.
Modifications
- In
MultiTopicsConsumerImpl.doAcknowledge(List<MessageId>, ...), remove only the per-consumermessageIdsfromunAckedMessageTrackerafter a successful ack. - Add
testBatchAcknowledgeRemovesOnlyAckedMessageIdsFromTrackerto verify that completing one consumer's batch ack leaves the other consumer's message in the tracker.
Verifying this change
- [x] Make sure that the change passes the CI checks.
This change added tests and can be verified as follows:
./gradlew :pulsar-client-original:test --tests org.apache.pulsar.client.impl.MultiTopicsConsumerImplTest.testBatchAcknowledgeRemovesOnlyAckedMessageIdsFromTracker
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
- [ ] Dependencies (add or upgrade a dependency)
- [ ] The public API
- [ ] The schema
- [ ] The default values of configurations
- [ ] The threading model
- [ ] The binary protocol
- [ ] The REST endpoints
- [ ] The admin CLI options
- [ ] The metrics
- [ ] Anything that affects deployment
The previous CI failure has been fixed on master. @lhotari Please approve the pending workflows. Thanks!