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/06/08 04:35:03 UTC

[GitHub] [pulsar] merlimat commented on a change in pull request #10862: [Issue 10860][pulsar-metadata] Ensure metadata cache consistency across brokers

merlimat commented on a change in pull request #10862:
URL: https://github.com/apache/pulsar/pull/10862#discussion_r647101647



##########
File path: pulsar-metadata/src/main/java/org/apache/pulsar/metadata/cache/impl/MetadataCacheImpl.java
##########
@@ -229,7 +240,11 @@ public MetadataCacheImpl(MetadataStore store, MetadataSerde<T> serde) {
         return store.delete(path, Optional.empty())
                 .thenAccept(v -> {
                     // Mark in the cache that the object was removed
-                    objCache.put(path, FutureUtils.value(Optional.empty()));
+                    // objCache.put(path, FutureUtils.value(Optional.empty()));

Review comment:
       I think that we could either invalidate it from the cache here, do the read to set the watch, or again, since it's mostly related with the ZK, do it there

##########
File path: pulsar-metadata/src/main/java/org/apache/pulsar/metadata/cache/impl/MetadataCacheImpl.java
##########
@@ -209,8 +211,17 @@ public MetadataCacheImpl(MetadataStore store, MetadataSerde<T> serde) {
         store.put(path, content, Optional.of(-1L))
                 .thenAccept(stat -> {
                     // Make sure we have the value cached before the operation is completed
-                    objCache.put(path, FutureUtils.value(Optional.of(new CacheGetResult<>(value, stat))));
-                    future.complete(null);
+                    // In addition to caching the value, we need to add a watch on the path,
+                    // so when/if it changes on any other node, we are notified and we can
+                    // update the cache
+                    objCache.get(path).whenComplete( (stat2, ex) -> {

Review comment:
       I think this logic should belong more to the ZK implementation, where we can set the watch after the put




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

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