You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2018/09/15 14:51:00 UTC

[GitHub] jiazhai opened a new pull request #2590: Issue #2584: unacked message is not redelivered on time

jiazhai opened a new pull request #2590: Issue #2584: unacked message is not redelivered on time
URL: https://github.com/apache/incubator-pulsar/pull/2590
 
 
   ### Motivation
   
   unacked message is not redelivered after setting ackTimeout, but it is actually redelivered after 2*acktimeout.
   
   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.
   
   ### Modifications
   
   - move `toggle()` from behind if clause to before if clause.
   - add ut
   
   ### Result
   
   ut passed

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services