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 2021/04/13 16:22:22 UTC

[GitHub] [pulsar] merlimat commented on a change in pull request #10190: Fix usage of seekAsync in MessageImpl.hasMessageAvailable and flaky-test

merlimat commented on a change in pull request #10190:
URL: https://github.com/apache/pulsar/pull/10190#discussion_r612597029



##########
File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java
##########
@@ -1863,8 +1863,17 @@ public boolean hasMessageAvailable() throws PulsarClientException {
             }
 
             if (hasMoreMessages(lastMessageIdInBroker, startMessageId, resetIncludeHead)) {
-                booleanFuture.complete(true);
-                return booleanFuture;
+                //this situation will occur when :
+                // 1.We haven't read yet 2.The connection was reset multiple times
+                // 3.Broker has pushed messages to ReceiverQueue, but messages were cleaned due to connection reset
+                seekAsync(startMessageId).whenComplete((ignore, e) -> {
+                    if (e != null) {
+                        booleanFuture.complete(false);

Review comment:
       Couldn't we have the case here where the seekAsync fails and we return `false` for `hasMessageAvailable()`, when in reality there may be some message?




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