You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by bo...@apache.org on 2022/11/09 07:04:46 UTC

[pulsar] branch branch-2.9 updated (58d0cbf2d1a -> e9d87fa09d9)

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

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


    from 58d0cbf2d1a [fix][broker] Fix issue where leader broker information isn't available after 10 minutes (#17401)
     new aede60f7092 fix-12894 (#12896)
     new e9d87fa09d9 Fix metadata cache inconsistency on do refresh (#14283)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/pulsar/metadata/cache/impl/MetadataCacheImpl.java   | 10 +++-------
 .../java/org/apache/pulsar/metadata/MetadataCacheTest.java     |  3 ++-
 2 files changed, 5 insertions(+), 8 deletions(-)


[pulsar] 02/02: Fix metadata cache inconsistency on do refresh (#14283)

Posted by bo...@apache.org.
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

commit e9d87fa09d9710c11dea8f1a1f5968c8f48fa138
Author: Kai Wang <kw...@streamnative.io>
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 2a4d6bb406d..2cbe9a6dc19 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
@@ -266,10 +266,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
@@ -283,11 +280,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:


[pulsar] 01/02: fix-12894 (#12896)

Posted by bo...@apache.org.
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

commit aede60f7092bda0ca682333471a62a275ad88fb6
Author: JiangHaiting <ji...@apache.org>
AuthorDate: Wed Dec 1 05:09:08 2021 +0800

    fix-12894 (#12896)
    
    Co-authored-by: Jiang Haiting <ji...@didichuxing.com>
    (cherry picked from commit 2b939b7a8b0bf9ed2fd31353067033d049ea5350)
---
 .../org/apache/pulsar/metadata/cache/impl/MetadataCacheImpl.java   | 7 +++++--
 .../test/java/org/apache/pulsar/metadata/MetadataCacheTest.java    | 3 ++-
 2 files changed, 7 insertions(+), 3 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 49c8680550c..2a4d6bb406d 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
@@ -265,8 +265,11 @@ public class MetadataCacheImpl<T> implements MetadataCache<T>, Consumer<Notifica
 
     @Override
     public void refresh(String path) {
-        objCache.synchronous().invalidate(path);
-        objCache.synchronous().refresh(path);
+        // Refresh object of path if only it is cached before.
+        if (objCache.getIfPresent(path) != null) {
+            objCache.synchronous().invalidate(path);
+            objCache.synchronous().refresh(path);
+        }
     }
 
     @VisibleForTesting
diff --git a/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/MetadataCacheTest.java b/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/MetadataCacheTest.java
index e7680296563..a4ba88852b0 100644
--- a/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/MetadataCacheTest.java
+++ b/pulsar-metadata/src/test/java/org/apache/pulsar/metadata/MetadataCacheTest.java
@@ -325,13 +325,14 @@ public class MetadataCacheTest extends BaseMetadataStoreTest {
     }
 
     @Test(dataProvider = "impl")
-    public void insertionOutsideCacheWithGenericType(String provider, Supplier<String> urlSupplier) throws Exception {
+    public void updateOutsideCacheWithGenericType(String provider, Supplier<String> urlSupplier) throws Exception {
         @Cleanup
         MetadataStore store = MetadataStoreFactory.create(urlSupplier.get(), MetadataStoreConfig.builder().build());
         MetadataCache<Map<String, String>> objCache = store.getMetadataCache(new TypeReference<Map<String, String>>() {
         });
 
         String key1 = newKey();
+        objCache.get(key1);
 
         Map<String, String> v = new TreeMap<>();
         v.put("a", "1");