heesung-sn commented on code in PR #23515:
URL: https://github.com/apache/pulsar/pull/23515#discussion_r1828118699


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/OwnershipCache.java:
##########
@@ -170,7 +170,22 @@ public CompletableFuture<Optional<NamespaceEphemeralData>> 
getOwnerAsync(Namespa
 
         // If we're not the owner, we need to check if anybody else is
         String path = ServiceUnitUtils.path(suName);
-        return lockManager.readLock(path);
+        return lockManager.readLock(path).thenCompose(owner -> {
+            // If the current broker is the owner, attempt to reacquire 
ownership to avoid cache loss.
+            if (owner.isPresent() && owner.get().equals(selfOwnerInfo)) {
+                log.warn("Detected ownership loss for broker [{}] on namespace 
bundle [{}]. "
+                                + "Attempting to reacquire ownership to 
maintain cache consistency.",
+                        selfOwnerInfo, suName);
+                try {
+                    return 
tryAcquiringOwnership(suName).thenApply(Optional::ofNullable);
+                } catch (Exception e) {

Review Comment:
   why do we need to catch an exception here? tryAcquiringOwnership returns 
CompletableFuture.



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