jiazhai commented on issue #2584: unacked message is not redelivered in setting 
ackTimeout
URL: 
https://github.com/apache/incubator-pulsar/issues/2584#issuecomment-421387939
 
 
   @codelipenghui meet this issue in their usage. 
   The main reason is in UnAckedMessageTracker.
   ```
       public void start(PulsarClientImpl client, ConsumerBase<?> consumerBase, 
long ackTimeoutMillis) {
           this.stop();
           timeout = client.timer().newTimeout(new TimerTask() {
               @Override
               public void run(Timeout t) throws Exception {
                   if (isAckTimeout()) {   < === first timeout, it is false, 
because oldOpenSet is empty.
                       log.warn("[{}] {} messages have timed-out", 
consumerBase, oldOpenSet.size());
                       Set<MessageId> messageIds = new HashSet<>();
                       oldOpenSet.forEach(messageIds::add);
                       oldOpenSet.clear();
                       consumerBase.redeliverUnacknowledgedMessages(messageIds);
                   }
                   toggle();    < === toggle after timeout
                   timeout = client.timer().newTimeout(this, ackTimeoutMillis, 
TimeUnit.MILLISECONDS);
               }
           }, ackTimeoutMillis, TimeUnit.MILLISECONDS);
       }
   ```
   before first timeout, all messageId was added in CurrentSet, not in 
OldOpenSet, so isAckTimeout() is false, and `redeliverUnacknowledgedMessages` 
was not called at first timeout.
   
   The fix may move `toggle()` from behind if clause to before if clause.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to