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


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/metacache/MetaCacheEntry.java:
##########
@@ -107,7 +127,13 @@ public MetaCacheEntry(String name, @Nullable Function<K, 
V> loader, CacheSpec ca
                 maxSize,
                 true,
                 null);
-        this.loadingData = 
cacheFactory.buildCache(this::loadFromDefaultLoader, refreshExecutor);
+        if (retirementListener != null) {
+            this.loadingData = cacheFactory.buildCacheWithSyncRemovalListener(

Review Comment:
   Fixed in e2b702e1b6c. The retirement-listener path now keeps the configured 
refresh executor instead of installing Runnable::run for the shared Caffeine 
executor. Rejected executor submissions fall back inline so retirement is not 
dropped. A FakeTicker and blocked-reload regression proves a stale hit returns 
the old value before reload completes; the focused suite passed.



##########
fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergExternalCatalog.java:
##########
@@ -173,17 +188,95 @@ protected List<String> 
listTableNamesFromRemote(SessionContext ctx, String dbNam
     }
 
     @Override
-    public void onClose() {
+    public synchronized void onClose() {
+        ThreadPoolExecutor retiredExecutor = threadPoolWithPreAuth;
+        threadPoolWithPreAuth = null;
         super.onClose();
-        if (null != catalog) {
-            try {
-                if (catalog instanceof AutoCloseable) {
-                    ((AutoCloseable) catalog).close();
-                }
-                catalog = null;
-            } catch (Exception e) {
-                LOG.warn("Failed to close iceberg catalog: {}", getName(), e);
+        Catalog retiredCatalog = catalog;
+        catalog = null;
+        resourceTracker.retireCurrent(() -> {
+            closeCatalog(retiredCatalog);
+            if (retiredExecutor != null) {
+                ThreadPoolManager.shutdownExecutorService(retiredExecutor);
             }
+        });
+    }
+
+    @Override
+    public synchronized void resetToUninitialized(boolean invalidCache) {
+        ExternalMetaCacheMgr cacheMgr = 
Env.getCurrentEnv().getExtMetaCacheMgr();
+        cacheMgr.runCatalogLifecycle(getId(), () -> 
resetCatalogRuntime(cacheMgr, invalidCache));
+    }
+
+    private void resetCatalogRuntime(ExternalMetaCacheMgr cacheMgr, boolean 
invalidCache) {
+        cacheMgr.removeCatalogByEngine(getId(), 
IcebergExternalMetaCache.ENGINE);
+        super.resetToUninitialized(invalidCache);
+    }
+
+    private void closeCatalog(Catalog retiredCatalog) {
+        if (retiredCatalog == null) {
+            return;
+        }
+        try {
+            if (retiredCatalog instanceof AutoCloseable) {
+                ((AutoCloseable) retiredCatalog).close();

Review Comment:
   Fixed in e2b702e1b6c. Both native Iceberg-HMS and the HMS fallback now 
construct DorisHiveCatalog, an idempotent generation owner that captures and 
closes the shared HiveCatalog FileIO in addition to BaseMetastoreCatalog.close. 
The HMS tracker callback now closes the retired catalog itself after detaching 
IcebergMetadataOps. Repeated-close coverage and the focused suite passed.



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