924060929 commented on code in PR #69629:
URL: https://github.com/apache/doris/pull/69629#discussion_r4385353091


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/MetaCache.java:
##########
@@ -662,6 +687,90 @@ public void invalidate(String localName, long id) {
         }
     }
 
+    /** Fences old object loads while retaining unrelated cached objects and 
their ID mappings. */
+    public void invalidateLookup(String localName, boolean allObjects) {
+        metaObjLifecycleLock.writeLock().lock();
+        try {
+            synchronized (namesMutationLock) {
+                invalidateNames();
+                metaObjGeneration.incrementAndGet();
+                lookupObservationGeneration++;
+                if (allObjects) {
+                    metaObjCache.invalidateAll();
+                    idToName.clear();
+                } else {
+                    metaObjCache.invalidate(localName);
+                    idToName.entrySet().removeIf(entry -> 
entry.getValue().equals(localName));
+                }
+            }
+        } finally {
+            metaObjLifecycleLock.writeLock().unlock();
+        }
+    }
+
+    /** Blocks missing-result repair during a metadata-only refresh without 
evicting names or objects. */
+    public Runnable beginMetadataRefresh() {
+        metaObjLifecycleLock.writeLock().lock();
+        try {
+            metadataRefreshes++;
+            lookupObservationGeneration++;
+        } finally {
+            metaObjLifecycleLock.writeLock().unlock();
+        }
+        return () -> {
+            metaObjLifecycleLock.writeLock().lock();
+            try {
+                metadataRefreshes--;
+                lookupObservationGeneration++;
+            } finally {
+                metaObjLifecycleLock.writeLock().unlock();
+            }
+        };
+    }
+
+    /** Captures matching resident membership and object state; never loads 
remote metadata. */
+    public Optional<Runnable> observeLookup(String localName, String 
remoteName, T expected,
+            boolean allObjects, Runnable invalidateMetadata) {
+        metaObjLifecycleLock.readLock().lock();
+        try {
+            synchronized (namesMutationLock) {
+                NamesCacheValue names = namesCache.getIfPresent("");
+                Optional<T> value = metaObjCache.getIfPresent(localName);
+                Pair<String, String> pair = names == null ? null : 
names.names.get(localName);
+                if (metadataRefreshes != 0 || names == null || !names.complete 
|| pair == null

Review Comment:
   Fixed in 544728845682. A complete names snapshot that omits the name can now 
authorize retirement of its matching resident object and ID after definite 
absence. Existing catalog/DB, names/object and metadata-refresh fences still 
apply. A current folded alias (old Foo vs published new FOO) fences DB-wide 
cleanup. Tests cover names-refresh-first SHOW CREATE retirement, omitted-name 
observations, same-name replacement, later names/metadata refresh, 
incomplete/conflicting membership, and folded aliases.
   
   Validation: 253 distinct selected FE cases passed across the broad run and 
the full 63-case MetaCache rerun after the final folded-alias guard; FE build 
and Checkstyle passed. New SDK failures are mocked; no live-service/full SQL 
analyzer integration claim.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to