github-actions[bot] commented on code in PR #69629:
URL: https://github.com/apache/doris/pull/69629#discussion_r4385226347


##########
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:
   [P2] Retire hot identities when refreshed names already omit the table
   
   In a case-sensitive HMS catalog, warm `SHOW TABLES` and `DESC ctl.db.t`, 
drop `t` remotely, and let the normal asynchronous names refresh finish so a 
later `SHOW TABLES` omits it. `loadNames()` replaces only the names snapshot; 
the old table object and `idToName` entry remain. `getTableNullable("t")` still 
returns that object through `getMetaObjInternal()`'s resident fast path. A 
subsequent `SHOW CREATE TABLE ctl.db.t` performs the guarded live HMS read and 
confirms `NoSuchObjectException`, but this `pair == null` check prevents any 
repair action. Repeated requests keep the old object hot, and numeric lookup 
continues resolving the dropped table indefinitely. Permit repair of the 
matching resident object/ID when the retained complete names snapshot already 
omits the name (or retire omitted objects during names refresh), while 
preserving replacement/epoch fences. Add a names-refresh-first regression 
asserting object and numeric-route retirement. This is distinct from the prior 
SHOW
  CREATE entry-point thread: the read now enters the guard, but observation 
rejects the refreshed membership state.



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