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 2021/06/14 14:53:29 UTC

[GitHub] [pulsar] codelipenghui commented on a change in pull request #10920: [broker] Fix issue where Key_Shared consumers could get stuck

codelipenghui commented on a change in pull request #10920:
URL: https://github.com/apache/pulsar/pull/10920#discussion_r651021560



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentStickyKeyDispatcherMultipleConsumers.java
##########
@@ -121,8 +121,14 @@ public synchronized void addConsumer(Consumer consumer) throws BrokerServiceExce
 
     @Override
     public synchronized void removeConsumer(Consumer consumer) throws BrokerServiceException {
-        super.removeConsumer(consumer);
+        // The consumer must be removed from the selector before calling the superclass removeConsumer method.
+        // In the superclass removeConsumer method, the pending acks that the consumer has are added to
+        // messagesToRedeliver. If the consumer has not been removed from the selector at this point,

Review comment:
       > If the consumer has not been removed from the selector at this point
   
   Looks like a race condition between sending messages to the consumer and remove the consumer from the selector?
   
   We have a `synchronized` to protect the `readEntriesComplete` and `removeConsumer`. How can this happen?




-- 
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:
users@infra.apache.org