You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by rx...@apache.org on 2020/11/02 02:51:47 UTC
[pulsar] 01/04: Fix deadlock that occurred during topic ownership
check (#8406)
This is an automated email from the ASF dual-hosted git repository.
rxl pushed a commit to branch branch-2.6
in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit fe3a258c3a696683009d8ff2771a3e4df757ea7f
Author: Masahiro Sakamoto <ma...@yahoo-corp.jp>
AuthorDate: Fri Oct 30 04:00:37 2020 +0900
Fix deadlock that occurred during topic ownership check (#8406)
(cherry picked from commit f96bc6305f54cd1845af64707ba4b94a7e9d861a)
---
.../apache/pulsar/broker/namespace/NamespaceService.java | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java
index f2995ee..a1acf28 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java
@@ -931,7 +931,19 @@ public class NamespaceService {
if (bundle.isPresent()) {
return ownershipCache.getOwnedBundle(bundle.get()) != null;
} else {
- return ownershipCache.getOwnedBundle(getBundle(topicName)) != null;
+ // Calling `getBundle(TopicName)` here can cause a deadlock.
+ // cf. https://github.com/apache/pulsar/pull/4190
+ //
+ // This method returns false once if the bundle metadata is not cached, but gets the metadata asynchronously
+ // to cache it. Otherwise, the clients will never be able to connect to the topic due to ServiceUnitNotReadyException.
+ // cf. https://github.com/apache/pulsar/pull/5919
+ getBundleAsync(topicName).thenAccept(bundle2 -> {
+ LOG.info("Succeeded in getting bundle {} for topic - [{}]", bundle2, topicName);
+ }).exceptionally(ex -> {
+ LOG.warn("Failed to get bundle for topic - [{}] {}", topicName, ex.getMessage());
+ return null;
+ });
+ return false;
}
}