diqiu50 commented on code in PR #12404:
URL: https://github.com/apache/gravitino/pull/12404#discussion_r3925376521


##########
core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java:
##########
@@ -438,18 +579,27 @@ public CatalogManager(
   }
 
   /**
-   * Closes the CatalogManager and releases any resources associated with it. 
This method
-   * invalidates all cached catalog instances and clears the cache.
+   * Closes the CatalogManager and invalidates all cached catalog instances. 
Idle resources are
+   * released immediately; resources protected by active leases are released 
when their last lease
+   * is closed.
    */
   @Override
   public void close() {
+    if (!closed.compareAndSet(false, true)) {

Review Comment:
   Should set(true) only be called after the operation is completed 
successfully.



##########
core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java:
##########
@@ -438,18 +579,27 @@ public CatalogManager(
   }
 
   /**
-   * Closes the CatalogManager and releases any resources associated with it. 
This method
-   * invalidates all cached catalog instances and clears the cache.
+   * Closes the CatalogManager and invalidates all cached catalog instances. 
Idle resources are
+   * released immediately; resources protected by active leases are released 
when their last lease
+   * is closed.
    */
   @Override
   public void close() {
+    if (!closed.compareAndSet(false, true)) {
+      return;
+    }
     if (catalogChangeLogListener != null) {
       ((SupportsEntityChangeLog) 
store).unregisterEntityChangeLogListener(catalogChangeLogListener);
       trackLocalMutations = false;
       localMutationCounts.clear();
     }
+    List<CatalogWrapper> wrappers = new 
ArrayList<>(catalogCache.asMap().values());

Review Comment:
   Copying the map without holding the lock may cause some entries to be missed.



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