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


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java:
##########
@@ -1172,8 +1206,12 @@ public void unregisterDatabase(String dbName) {
         if (LOG.isDebugEnabled()) {
             LOG.debug("unregister database [{}]", dbName);
         }
+        // When lower_case_database_names = 2, database lookup is 
case-insensitive but the database
+        // object cache still uses the preserved remote/original-case name as 
its key. Event replay
+        // passes that same preserved name here, so invalidation intentionally 
follows the same key
+        // convention before cleaning local state.
         if (isInitialized()) {
-            metaCache.invalidate(dbName, Util.genIdByName(name, dbName));
+            invalidateDatabaseCache(dbName);

Review Comment:
   Mode 2 invalidation needs to use the canonical local key, not the raw 
request/log name. `dropDbImpl()` resolves a request like `drop database 
mixeddb` to the hot `MixedDb` object and drops `dorisDb.getRemoteName()`, but 
`ExternalMetadataOps.dropDb()` then calls `afterDropDb(dbName)` and the edit 
log stores that original `dbName`. Here `invalidateDatabaseCache("mixeddb")` 
removes from `databaseNames`, `databases`, and `dbIdToName` by exact key, while 
mode 2 stores the preserved `MixedDb` key. The stale names/object/id entries 
remain hot, so `getDbNullable("mixeddb")` can resolve through the old 
`NameCacheValue` and return the dropped DB without reloading. Please 
canonicalize against the hot name/object cache, or log/pass 
`dorisDb.getFullName()`, before invalidating.
   



##########
fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalDatabase.java:
##########
@@ -626,17 +732,17 @@ public void unregisterTable(String tableName) {
             LOG.debug("unregister table {}.{}", this.name, tableName);
         }
         setLastUpdateTime(System.currentTimeMillis());
-        // check if the table exists in cache, it not, does return
-        ExternalTable dorisTable = getTableForReplay(tableName).orElse(null);
+        // Mode 2 keeps the preserved remote/original-case name as the 
object-cache key, and the
+        // unregister path intentionally follows the same key convention 
before invalidating local state.
+        String localTableName = toLocalTableName(tableName);
+        ExternalTable dorisTable = 
getTableForReplay(localTableName).orElse(null);
+        // Always clean local names/object/ID state, even when the object 
entry is cold or already evicted.
+        if (isInitialized()) {
+            invalidateTableCache(localTableName);

Review Comment:
   Same key mismatch on the table path for replay/rename: this can find the 
canonical object but then invalidate the raw spelling. In mode 2, 
`getTableForReplay("foo")` can resolve the hot `Foo` object via 
`NameCacheValue`, but `localTableName` stays `"foo"` because 
`toLocalTableName()` preserves its input. `invalidateTableCache("foo")` then 
misses the `tableNames`, `tables`, and `tableIdToName` entries keyed by 
`"Foo"`. Leader `DROP TABLE` uses `dorisTable.getName()` in the callback, but 
the edit log records the user spelling and `replayDropTable()`/rename replay 
pass that raw name here, so the old table can remain visible. Use the resolved 
`dorisTable.getName()` or another canonical hot key for invalidation.
   



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