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


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/paimon/PaimonTableLoader.java:
##########
@@ -32,6 +33,34 @@
  */
 public final class PaimonTableLoader {
 
+    public void invalidate(NameMapping nameMapping) {
+        try {
+            catalog(nameMapping).invalidatePaimonTable(nameMapping);
+        } catch (Exception e) {
+            throw new CacheException("failed to invalidate paimon table 
%s.%s.%s: %s",

Review Comment:
   Fixed in a25cf59d22b1fdbaea0d217197298ba3818bb433. 
PaimonMetadataOps.afterDropTable is now best-effort: it catches and logs 
cache-invalidation failures (including the CacheException raised by 
PaimonTableLoader.invalidate), so the committed remote table drop is still 
journaled by ExternalCatalog.dropTable and followers can replay it. Added 
testAfterDropTableInvalidationFailureIsBestEffort, which injects a throwing 
unregisterTableForReplay.



##########
fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonMetadataOps.java:
##########
@@ -358,11 +382,19 @@ private void performDropTable(String dBName, String 
tableName, boolean ifExists)
     @Override
     public void afterDropTable(String dbName, String tblName) {
         Optional<ExternalDatabase<?>> db = dorisCatalog.getDbForReplay(dbName);
-        db.ifPresent(externalDatabase -> 
externalDatabase.unregisterTable(tblName));
+        boolean invalidated = db.isPresent() && 
db.get().unregisterTableForReplay(tblName);
+        if (!invalidated) {
+            invalidatePaimonCatalogForUnresolvedReplay();

Review Comment:
   Fixed in a25cf59d22b1fdbaea0d217197298ba3818bb433. On the unresolved branch 
(database object not present), afterDropTable now calls 
ExternalCatalog.retireAllDatabaseObjectsWithoutEngineInvalidation() before 
flushing the engine group, so an alternate-case DROP TABLE replay after a lost 
mode-2 mapping cannot leave the canonical ExternalDatabase (and its nested 
table-name cache) for a same-name recreation. Added 
testMode2UnresolvedTableDropRetiresCanonicalLegacyDatabase.



##########
fe/fe-core/src/main/java/org/apache/doris/datasource/operations/ExternalMetadataOps.java:
##########
@@ -78,15 +78,34 @@ default void afterCreateDb() {
      * @param force
      * @throws DdlException
      */
-    default void dropDb(String dbName, boolean ifExists, boolean force) throws 
DdlException {
-        dropDbImpl(dbName, ifExists, force);
+    default boolean dropDb(String dbName, boolean ifExists, boolean force) 
throws DdlException {
+        if (!dropDbImpl(dbName, ifExists, force)) {
+            // No remote mutation happened, so do not run the post-drop hook 
or journal the
+            // operation. A retained local incarnation may still need cleanup 
(for example a lost
+            // case-insensitive name mapping), so give the implementation a 
separate hook.
+            afterDropDbNoOp(dbName);
+            return false;
+        }
         afterDropDb(dbName);
+        return true;
     }
 
-    void dropDbImpl(String dbName, boolean ifExists, boolean force) throws 
DdlException;
+    /**
+     * @return whether the remote database was dropped. Returns {@code false} 
when the call was a
+     *         no-op (for example {@code IF EXISTS} on a database that does 
not exist).
+     */
+    boolean dropDbImpl(String dbName, boolean ifExists, boolean force) throws 
DdlException;
 
     void afterDropDb(String dbName);
 
+    /**
+     * Cleanup hook for a drop that did not mutate the remote metastore (for 
example
+     * {@code DROP DATABASE IF EXISTS} on a database that does not exist). 
Implementations use it to
+     * retire any retained local object without the cache work of a real drop.
+     */
+    default void afterDropDbNoOp(String dbName) {

Review Comment:
   Fixed in a25cf59d22b1fdbaea0d217197298ba3818bb433. The default 
ExternalMetadataOps.afterDropDbNoOp now calls afterDropDb(dbName), restoring 
the pre-existing local cleanup (unregisterDatabase) for Hive, Iceberg, and 
MaxCompute on a no-op IF EXISTS drop, while Paimon keeps its targeted override 
that avoids the broad SDK flush.



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