You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by lh...@apache.org on 2022/02/15 10:43:43 UTC
[pulsar] branch master updated: Fix metadata cache inconsistency on do refresh (#14283)
This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 2e16b43 Fix metadata cache inconsistency on do refresh (#14283)
2e16b43 is described below
commit 2e16b4341682083a329b63ffaae6d2df2eeec3c5
Author: Kai Wang <kw...@streamnative.io>
AuthorDate: Tue Feb 15 18:42:13 2022 +0800
Fix metadata cache inconsistency on do refresh (#14283)
---
.../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 a49bed2..67fa7af 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
@@ -263,10 +263,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
@@ -280,11 +277,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: