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/12/21 17:50:06 UTC

[GitHub] [pulsar] lhotari commented on a change in pull request #13428: [Broker] Fix race conditions in closing producers and consumers

lhotari commented on a change in pull request #13428:
URL: https://github.com/apache/pulsar/pull/13428#discussion_r773334755



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -292,24 +292,30 @@ public void channelInactive(ChannelHandlerContext ctx) throws Exception {
 
         // Connection is gone, close the producers immediately
         producers.forEach((__, producerFuture) -> {
+            // prevent race conditions in completing producers
+            if (!producerFuture.isDone()
+                    && producerFuture.completeExceptionally(new IllegalStateException("Connection closed."))) {

Review comment:
       no, it's different. Creating an exception is a heavy operation and the original version prevents that from happening if it's done.




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org