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



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java
##########
@@ -184,7 +184,7 @@ public synchronized void removeConsumer(Consumer consumer) 
throws BrokerServiceE
                     messagesToRedeliver.add(ledgerId, entryId);
                     redeliveryTracker.addIfAbsent(PositionImpl.get(ledgerId, 
entryId));
                 });
-                totalAvailablePermits -= consumer.getAvailablePermits();
+                TOTAL_AVAILABLE_PERMITS_UPDATER.addAndGet(this, 
-consumer.getAvailablePermits());

Review comment:
       The increments/decrement on the `totalAvailablePermits` should already 
be safe because they're all done while holding the mutex on the dispatcher 
object.

##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java
##########
@@ -175,7 +175,7 @@ public synchronized void removeConsumer(Consumer consumer) 
throws BrokerServiceE
                     log.info("[{}] All consumers removed. Subscription is 
disconnected", name);
                     closeFuture.complete(null);
                 }
-                totalAvailablePermits = 0;
+                TOTAL_AVAILABLE_PERMITS_UPDATER.set(this, 0);

Review comment:
       This would be equivalent to `totalAvailablePermits = 0` 




-- 
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:
[email protected]


Reply via email to