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 2022/10/24 03:10:27 UTC

[GitHub] [pulsar] lordcheng10 commented on a diff in pull request #18164: [fix][broker] AVAILABLE_PERMITS_UPDATER not updated, when writeAndFlush fails.

lordcheng10 commented on code in PR #18164:
URL: https://github.com/apache/pulsar/pull/18164#discussion_r1002851279


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java:
##########
@@ -972,6 +972,22 @@ private void sendFlowPermitsToBroker(ClientCnx cnx, int numMessages) {
             if (log.isDebugEnabled()) {
                 log.debug("[{}] [{}] Adding {} additional permits", topic, subscription, numMessages);
             }
+
+            cnx.ctx().writeAndFlush(Commands.newFlow(consumerId, numMessages))
+                    .addListener(writeFuture -> {
+                        String msg;
+                        if (!writeFuture.isSuccess()) {
+                            msg = String.format("Consumer {} failed to send {} permits to broker: {}"
+                                    , consumerId, numMessages, writeFuture.cause().getMessage());
+                            increaseAvailablePermits(cnx, numMessages, false);
+                        } else {
+                            msg = String.format("Consumer {} sent {} permits to broker", consumerId, numMessages);
+                        }
+                        if (log.isDebugEnabled()) {
+                            log.debug(msg);
+                        }
+                    });
+
             if (log.isDebugEnabled()) {

Review Comment:
   Fixed.



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

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org