Lanayx opened a new issue #7683:
URL: https://github.com/apache/pulsar/issues/7683


   **Describe the bug**
   Issue can happen when acknowledge request fails due to temporary network 
failure. The root of the issue is that [isDuplicate method depends on 
lastCumulativeAck 
field](https://github.com/apache/pulsar/blob/branch-2.6/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PersistentAcknowledgmentsGroupingTracker.java#L103)
 which [is updated before the acknowledgment request 
succeeds](https://github.com/apache/pulsar/blob/branch-2.6/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PersistentAcknowledgmentsGroupingTracker.java#L163)
 and [cumulativeAckFlushRequired is updated before 
that](https://github.com/apache/pulsar/blob/branch-2.6/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PersistentAcknowledgmentsGroupingTracker.java#L230).
 Therefore on failure lastCumulativeAck will stay at messageId that wasn't 
actually acked and unacked messages will be rejected on redelivery as 
duplicates.
   
   **To Reproduce**
   Steps to reproduce the behavior:
   
   let say we have 10 messages in a queue
   
   1. Do batch acknowledge for the last message (to acknowledge all)
   2. Temporary network failure happens and acknowledgement flush fails, while 
lastCumulativeAck becomes set to 10th message
   3. Consumer reconnects and all 10 messages are redelivered
   4. All 10 messages will be rejected as duplicates and won't be consumed 
again until consumer restart. On consumer restart they will be redelivered and 
reprocessed.
   
   **Expected behavior**
   10 messages will be reconsumed normally or even better - reacknowledged 
transparently without consuming by the application
   
   **Additional context**
   _Idea:_
   As pulsar [doesn't support acknowledge guarantees 
](https://github.com/apache/pulsar/pull/4768#issuecomment-520109887), this 
prevents having "effectively once delivery", since consumer is expected to 
process the messages that were unable to be acked twice. Transparent 
reacknowledgment of such messages on redelivery (for both normal and cumulative 
acknowledgment) can fix this issue for the most cases.
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to