jerqi commented on code in PR #6717:
URL: https://github.com/apache/gravitino/pull/6717#discussion_r2002804267


##########
core/src/main/java/org/apache/gravitino/hook/CatalogHookDispatcher.java:
##########
@@ -82,21 +85,26 @@ public Catalog createCatalog(
 
     Catalog catalog = dispatcher.createCatalog(ident, type, provider, comment, 
properties);
 
-    // Set the creator as the owner of the catalog.
-    OwnerManager ownerManager = GravitinoEnv.getInstance().ownerManager();
-    if (ownerManager != null) {
-      ownerManager.setOwner(
-          ident.namespace().level(0),
-          NameIdentifierUtil.toMetadataObject(ident, 
Entity.EntityType.CATALOG),
-          PrincipalUtils.getCurrentUserName(),
-          Owner.Type.USER);
-    }
+    try {
+      // Set the creator as the owner of the catalog.
+      OwnerManager ownerManager = GravitinoEnv.getInstance().ownerManager();
+      if (ownerManager != null) {
+        ownerManager.setOwner(
+            ident.namespace().level(0),
+            NameIdentifierUtil.toMetadataObject(ident, 
Entity.EntityType.CATALOG),
+            PrincipalUtils.getCurrentUserName(),
+            Owner.Type.USER);
+      }
 
-    // Apply the metalake securable object privileges to authorization plugin
-    FutureGrantManager futureGrantManager = 
GravitinoEnv.getInstance().futureGrantManager();
-    if (futureGrantManager != null && catalog instanceof BaseCatalog) {
-      futureGrantManager.grantNewlyCreatedCatalog(
-          ident.namespace().level(0), (BaseCatalog) catalog);
+      // Apply the metalake securable object privileges to authorization plugin
+      FutureGrantManager futureGrantManager = 
GravitinoEnv.getInstance().futureGrantManager();
+      if (futureGrantManager != null && catalog instanceof BaseCatalog) {
+        futureGrantManager.grantNewlyCreatedCatalog(
+            ident.namespace().level(0), (BaseCatalog) catalog);
+      }
+    } catch (Exception e) {
+      LOG.warn("Fail to execute the post hook operations, rollback the catalog 
" + ident, e);
+      dispatcher.dropCatalog(ident, true);

Review Comment:
   1. CatalogManager has similar logics and catalog creation don't involve 
other external systems. So I aligned to the CatalogManger's logic.
   2. I think that we don't need. Schema and table don't have similar logic to 
catalog about rollback.



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