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


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/RefreshManager.java:
##########
@@ -281,6 +288,7 @@ public void refreshPartitions(String catalogName, String 
dbName, String tableNam
         for (String partitionName : partitionNames) {
             cache.invalidatePartitionCache(externalTable, partitionName);
         }
+        
Env.getCurrentEnv().getExtMetaCacheMgr().invalidateRowCountCache(externalTable);
         ((HMSExternalTable) table).setUpdateTime(updateTime);

Review Comment:
   Fixed in 48fea1dd796. `refreshPartitions()` now publishes the row-count 
invalidation fence before the fallible Hive cache lookup and per-partition 
invalidation. Added `testAlterPartitionInvalidatesRowCountBeforeCacheFailure` 
to verify the fence is still published when that lookup throws.



##########
fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java:
##########
@@ -1228,10 +1238,24 @@ public void unregisterDatabase(String dbName) {
         if (LOG.isDebugEnabled()) {
             LOG.debug("unregister database [{}]", dbName);
         }
-        if (isInitialized()) {
-            metaCache.invalidate(dbName, Util.genIdByName(name, dbName));
+        // Resolve the canonical database object before removing it from the 
local metadata cache.
+        // The row-count cache can outlive that object and must be invalidated 
by its numeric id.
+        boolean catalogInitialized = isInitialized();
+        Optional<ExternalDatabase<? extends ExternalTable>> db = 
catalogInitialized
+                ? getDbForReplay(dbName) : Optional.empty();
+        String localDbName = 
db.map(ExternalDatabase::getFullName).orElse(dbName);
+        long dbId = db.map(ExternalDatabase::getId).orElseGet(() -> 
Util.genIdByName(name, localDbName));

Review Comment:
   Fixed in 48fea1dd796. Database removal now resolves the canonical local name 
from the name mapping independently of object-cache residency, and mode 1/2 
uses that canonical name and its deterministic ID even when the DB object is 
cold. Added a mode-2 cold-removal regression test.



##########
fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java:
##########
@@ -1228,10 +1238,24 @@ public void unregisterDatabase(String dbName) {
         if (LOG.isDebugEnabled()) {
             LOG.debug("unregister database [{}]", dbName);
         }
-        if (isInitialized()) {
-            metaCache.invalidate(dbName, Util.genIdByName(name, dbName));
+        // Resolve the canonical database object before removing it from the 
local metadata cache.
+        // The row-count cache can outlive that object and must be invalidated 
by its numeric id.
+        boolean catalogInitialized = isInitialized();
+        Optional<ExternalDatabase<? extends ExternalTable>> db = 
catalogInitialized
+                ? getDbForReplay(dbName) : Optional.empty();
+        String localDbName = 
db.map(ExternalDatabase::getFullName).orElse(dbName);
+        long dbId = db.map(ExternalDatabase::getId).orElseGet(() -> 
Util.genIdByName(name, localDbName));
+        try {
+            if (db.isPresent()) {
+                Env.getCurrentEnv().getExtMetaCacheMgr().invalidateDb(getId(), 
dbId, localDbName);
+            } else {
+                Env.getCurrentEnv().getExtMetaCacheMgr().invalidateDb(getId(), 
dbName);
+            }
+        } finally {
+            if (catalogInitialized) {
+                metaCache.invalidate(localDbName, dbId);
+            }

Review Comment:
   Fixed in 48fea1dd796. Explicit database removal remains the sole owner of 
routed/row-count invalidation; while its synchronous MetaCache removal callback 
runs, the callback only resets the removed database object's local state. Added 
a regression test that verifies one manager invalidation and suppression in the 
callback.



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