rdhabalia opened a new pull request #13196:
URL: https://github.com/apache/pulsar/pull/13196


   ### Motivation
   
   We have been frequently seeing an issue with an exclusive subscription where 
the broker doesn't clean up consumers on closed on connection and because of 
that exclusive consumer keeps failing with `ConsumerBusyException` even though 
none of the consumers is actually connected to the broker.
   Below log example shows that connection is closed but still broker couldn't 
clean up consumer in race condition when consumer quickly disconnects after 
creating the subscription and subsequent consumer creation requests are keep 
failing.
   
   ```
   23:30:16.896 [pulsar-io-23-42] INFO  
org.apache.pulsar.broker.service.ServerCnx - [/10.11.12.13:60851] Subscribing 
on topic persistent://my-prop/my-cluster/ns/topic / sub1
   :
   23:30:17.223 [pulsar-io-23-42] INFO  
org.apache.pulsar.broker.service.ServerCnx - [/10.11.12.13:60851] Closed 
consumer, consumerId=20
   :
   23:30:17.291 [bookkeeper-ml-workers-OrderedExecutor-1-0] INFO  
org.apache.pulsar.broker.service.persistent.PersistentTopic - 
[persistent://my-prop/my-cluster/ns/topic][sub1] Created new subscription for 25
   :
   23:30:17.301 [pulsar-io-23-42] INFO  
org.apache.pulsar.broker.service.ServerCnx - Closed connection from 
/10.11.12.13:60851
   :
   23:30:17.302 [pulsar-io-23-42] INFO  
org.apache.pulsar.broker.service.AbstractDispatcherSingleActiveConsumer - 
Removing consumer 
Consumer{subscription=PersistentSubscription{topic=persistent://my-prop/my-cluster/ns/topic,
 name=sub1}, consumerId=21, consumerName=c2302, address=/10.11.12.13:60851}
   :
   23:30:17.302 [bookkeeper-ml-workers-OrderedExecutor-1-0] INFO  
org.apache.pulsar.broker.service.ServerCnx - [/10.11.12.13:60851] Created 
subscription on topic persistent://my-prop/my-cluster/ns/topic / sub1
   :
   :
   :
   
   23:30:17.496 [pulsar-io-23-36] WARN  
org.apache.pulsar.broker.service.persistent.PersistentTopic - 
[persistent://my-prop/my-cluster/ns/topic][sub1] Consumer 25 7a977 already 
connected
   23:30:17.885 [pulsar-io-23-36] INFO  
org.apache.pulsar.broker.service.ServerCnx - [/10.11.12.13:60853] Subscribing 
on topic persistent://my-prop/my-cluster/ns/topic / sub1
   23:30:17.886 [pulsar-io-23-36] WARN  
org.apache.pulsar.broker.service.persistent.PersistentTopic - 
[persistent://my-prop/my-cluster/ns/topic][sub1] Consumer 25 7a977 already 
connected
   23:30:18.637 [pulsar-io-23-36] INFO  
org.apache.pulsar.broker.service.ServerCnx - [/10.11.12.13:60853] Subscribing 
on topic persistent://my-prop/my-cluster/ns/topic / sub1
   ```
   
   ### Modification
   Broker should clean up consumer if connection is already closed and allow 
consumer to reconnect as an active consumer.


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