michaeljmarshall commented on code in PR #19446:
URL: https://github.com/apache/pulsar/pull/19446#discussion_r1098262726


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java:
##########
@@ -2813,21 +2824,30 @@ public void removedConsumer(Consumer consumer) {
 
     @Override
     public void removedProducer(Producer producer) {
-        safelyRemoveProducer(producer);
+        safelyRemoveProducer(producer, false);
     }
 
-    private void safelyRemoveProducer(Producer producer) {
+    private void safelyRemoveProducer(Producer producer, boolean 
keepTombstoneForProducer) {
         long producerId = producer.getProducerId();
         if (log.isDebugEnabled()) {
             log.debug("[{}] Removed producer: producerId={}, producer={}", 
remoteAddress, producerId, producer);
         }
         CompletableFuture<Producer> future = producers.get(producerId);
         if (future != null) {
-            future.whenComplete((producer2, exception) -> {
+            future.whenCompleteAsync((producer2, exception) -> {
                     if (exception != null || producer2 == producer) {
                         producers.remove(producerId, future);
+                        if (keepTombstoneForProducer
+                                && isActive
+                                && getRemoteEndpointProtocolVersion() >= 
v5.getValue()) {

Review Comment:
   My refactored solution should make this a bit clearer. We only need to keep 
track of the producers that we close via the `CloseProducer` 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to