Jason918 commented on a change in pull request #13196:
URL: https://github.com/apache/pulsar/pull/13196#discussion_r772873784



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
##########
@@ -804,6 +804,16 @@ protected void handleProducerRemoved(Producer producer) {
                 if (ex.getCause() instanceof ConsumerBusyException) {
                     log.warn("[{}][{}] Consumer {} {} already connected", 
topic, subscriptionName, consumerId,
                             consumerName);
+                    Consumer consumer = null;
+                    try {
+                        consumer = subscriptionFuture.isDone() ? 
getActiveConsumer(subscriptionFuture.get()) : null;
+                        // cleanup consumer if connection is already closed
+                        if (consumer != null && !consumer.cnx().isActive()) {
+                            consumer.close();

Review comment:
       > if consumer connection is not active and if consumer is still pretends 
as an active consumer then it requires cleanup by closing it immedaitely.
   
   I get what you are trying to do, and I am +1 for this.
   
   But do you agree that `consumer.close` may be called in two threads at the 
same time? 
   One is here, and the other may be in 
`org.apache.pulsar.broker.service.ServerCnx#channelInactive`.
   




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