Copilot commented on code in PR #11417:
URL: https://github.com/apache/gravitino/pull/11417#discussion_r3360065302


##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/system/storedprocedure/DropCatalogStoredProcedure.java:
##########
@@ -90,14 +92,23 @@ public void dropCatalog(String catalogName, boolean 
ignoreNotExist) {
           catalogConnectorManager.getCatalogConnector(
               catalogConnectorManager.getTrinoCatalogName(metalake, 
catalogName));
       if (catalogConnector == null) {
-        if (ignoreNotExist) {
-          return;
+        boolean dropped =
+            
catalogConnectorManager.getMetalake(metalake).dropCatalog(catalogName, true);
+        if (!dropped) {
+          if (ignoreNotExist) {
+            return;
+          }
+          throw new TrinoException(
+              GravitinoErrorCode.GRAVITINO_CATALOG_NOT_EXISTS,
+              "Catalog " + NameIdentifier.of(metalake, catalogName) + " not 
exists.");
         }
-
-        throw new TrinoException(
-            GravitinoErrorCode.GRAVITINO_CATALOG_NOT_EXISTS,
-            "Catalog " + NameIdentifier.of(metalake, catalogName) + " not 
exists.");
+        LOG.info(
+            "Drop catalog {} in metalake {} from server (no local connector) 
successfully.",
+            catalogName,
+            metalake);
+        return;

Review Comment:
   After a successful server-side drop in the local-cache-miss branch, the 
method returns without calling `catalogConnectorManager.loadMetalakeSync()` / 
checking `catalogConnectorExist(...)`. Because `CatalogConnectorManager` 
updates `catalogConnectors` asynchronously via its scheduled loader, a 
connector for this catalog can be added concurrently after the initial 
`getCatalogConnector(...)` null check. In that race, this procedure would drop 
the catalog on the server but leave a stale local connector registered until 
the next refresh cycle. Consider reusing the same sync-reload + existence check 
used in the non-null branch to ensure the local view is consistent immediately 
after the server-side drop.



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

Reply via email to