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 02:24:23 UTC
[GitHub] [pulsar] Jason918 commented on a diff in pull request #18164: [fix][broker] AVAILABLE_PERMITS_UPDATER not updated, when writeAndFlush fails.
Jason918 commented on code in PR #18164:
URL: https://github.com/apache/pulsar/pull/18164#discussion_r1002829765
##########
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);
Review Comment:
Can you add a test to verify this? Is it possible that when the flush fails, the connection would be invalid and new connection will be created.
##########
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:
+1, we can't send duplicated Flow command.
--
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