pulsar icon indicating copy to clipboard operation
pulsar copied to clipboard

[fix][client] Fix unAckedMessageTracker cleanup on multi-topics batch ack

Open Dream95 opened this issue 5 months ago • 1 comments

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-consumer messageIds from unAckedMessageTracker after a successful ack.
  • Add testBatchAcknowledgeRemovesOnlyAckedMessageIdsFromTracker to 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

Dream95 avatar Jun 11 '26 13:06 Dream95

The previous CI failure has been fixed on master. @lhotari Please approve the pending workflows. Thanks!

Dream95 avatar Jun 23 '26 09:06 Dream95