You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by mm...@apache.org on 2019/04/08 21:46:39 UTC

[pulsar] branch branch-2.3 updated: Fix deadlock during GC of non-persistent topic (#4003)

This is an automated email from the ASF dual-hosted git repository.

mmerli pushed a commit to branch branch-2.3
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/branch-2.3 by this push:
     new 7a6f2cc  Fix deadlock during GC of non-persistent topic (#4003)
7a6f2cc is described below

commit 7a6f2cca0fdb01e4a1ea1c72d907217a13af8ff1
Author: massakam <ma...@yahoo-corp.jp>
AuthorDate: Tue Apr 9 06:21:02 2019 +0900

    Fix deadlock during GC of non-persistent topic (#4003)
---
 .../broker/service/nonpersistent/NonPersistentTopic.java       | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/nonpersistent/NonPersistentTopic.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/nonpersistent/NonPersistentTopic.java
index bd60d95..b0cbf1c 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/nonpersistent/NonPersistentTopic.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/nonpersistent/NonPersistentTopic.java
@@ -465,9 +465,13 @@ public class NonPersistentTopic implements Topic {
                             isFenced = false;
                             deleteFuture.completeExceptionally(ex);
                         } else {
-                            brokerService.removeTopicFromCache(topic);
-                            log.info("[{}] Topic deleted", topic);
-                            deleteFuture.complete(null);
+                            // topic GC iterates over topics map and removing from the map with the same thread creates
+                            // deadlock. so, execute it in different thread
+                            brokerService.executor().execute(() -> {
+                                brokerService.removeTopicFromCache(topic);
+                                log.info("[{}] Topic deleted", topic);
+                                deleteFuture.complete(null);
+                            });
                         }
                     });
                 } else {