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

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


The following commit(s) were added to refs/heads/branch-2.9 by this push:
     new 977a81ce9b8 Fix metadata cache inconsistency on do refresh (#14283)
977a81ce9b8 is described below

commit 977a81ce9b8fd9bf9f7f82bb1f3d001f49dba083
Author: Kai Wang <[email protected]>
AuthorDate: Tue Feb 15 18:42:13 2022 +0800

    Fix metadata cache inconsistency on do refresh (#14283)
    
    (cherry picked from commit 2e16b4341682083a329b63ffaae6d2df2eeec3c5)
---
 .../apache/pulsar/metadata/cache/impl/MetadataCacheImpl.java  | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git 
a/pulsar-metadata/src/main/java/org/apache/pulsar/metadata/cache/impl/MetadataCacheImpl.java
 
b/pulsar-metadata/src/main/java/org/apache/pulsar/metadata/cache/impl/MetadataCacheImpl.java
index fccbe2ca38a..8bf5a729b76 100644
--- 
a/pulsar-metadata/src/main/java/org/apache/pulsar/metadata/cache/impl/MetadataCacheImpl.java
+++ 
b/pulsar-metadata/src/main/java/org/apache/pulsar/metadata/cache/impl/MetadataCacheImpl.java
@@ -262,10 +262,7 @@ public class MetadataCacheImpl<T> implements 
MetadataCache<T>, Consumer<Notifica
     @Override
     public void refresh(String path) {
         // Refresh object of path if only it is cached before.
-        if (objCache.getIfPresent(path) != null) {
-            objCache.synchronous().invalidate(path);
-            objCache.synchronous().refresh(path);
-        }
+        objCache.asMap().computeIfPresent(path, (oldKey, oldValue) -> 
readValueFromStore(path));
     }
 
     @VisibleForTesting
@@ -279,11 +276,7 @@ public class MetadataCacheImpl<T> implements 
MetadataCache<T>, Consumer<Notifica
         switch (t.getType()) {
         case Created:
         case Modified:
-            if (objCache.synchronous().getIfPresent(path) != null) {
-                // Trigger background refresh of the cached item, but before 
make sure
-                // to invalidate the entry so that we won't serve a stale 
cached version
-                refresh(path);
-            }
+            refresh(path);
             break;
 
         case Deleted:

Reply via email to