nodece commented on code in PR #23515:
URL: https://github.com/apache/pulsar/pull/23515#discussion_r1827022757


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/OwnershipCache.java:
##########
@@ -170,7 +170,17 @@ 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, we must try to acquire 
ownership to avoid cache loss.

Review Comment:
   @heesung-sn Thanks for your explanation. I think the ownership release 
protocol may work fine.
   
   > This PR looks ok to fix the possible cache and metadata inconsistency 
state.
   
   All right. I'm not sure if the issue is only in the pulsar testing 
environment.
   
   Please notice that the 
`org.apache.pulsar.client.api.BrokerServiceLookupTest.BundleOfTopic` class in 
the test.
   
   ```
           private void releaseBundleLockAndMakeAcquireFail() throws Exception {
               ownedBundlesCache.synchronous().invalidateAll();
               mockZooKeeper.delete(ServiceUnitUtils.path(namespaceBundle), -1);
               
mockZooKeeper.setAlwaysFail(KeeperException.Code.OPERATIONTIMEOUT);
           }
   ```
   
   This method directly discards the cache and deletes zk data,  which may 
break the test case.
   
   I will double-check the ownership mechanism to avoid the racing condition.



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