World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#9383] fix(iceberg): fix connect IRC failed after idle time (#9410)
FANNG4f192d6bd3a4
diff --git a/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.java b/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.javaindex 54513e9a15..04c0627dfb 100644--- a/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.java+++ b/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.java@@ -281,6 +281,7 @@ public class IcebergCatalogWrapper implements AutoCloseable {@Overridepublic void close() throws Exception {+ LOG.info("Closing IcebergCatalogWrapper for catalog: {}", catalog.name());if (catalog instanceof AutoCloseable) {// JdbcCatalog and ClosableHiveCatalog implement AutoCloseable and will handle their own// cleanup@@ -288,6 +289,26 @@ public class IcebergCatalogWrapper implements AutoCloseable {}metadataCache.close();+ // For Iceberg REST server which use the same classloader when recreating catalog wrapper, the+ // Driver couldn't be reloaded after deregister()+ if (useDifferentClassLoader()) {+ closeJdbcDriverResources();+ }+ }++ /**+ * Whether the wrapper is recreated with a different classloader.+ *+ * <p>Returning {@code true} allows JDBC drivers loaded by an isolated classloader to be+ * deregistered when the wrapper closes so the classloader can be garbage collected. Implementors+ * that intentionally reuse the same classloader (for example, an Iceberg REST server instance)+ * should override and return {@code false} to skip deregistration.+ */+ protected boolean useDifferentClassLoader() {+ return true;+ }++ private void closeJdbcDriverResources() {// Because each catalog in Gravitino has its own classloader, after a catalog is no longer used// for a long time or dropped, the instance of classloader needs to be released. In order to// let JVM GC remove the classloader, we need to release the resources of the classloader. Thediff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/CatalogWrapperForREST.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/CatalogWrapperForREST.javaindex 2c96cfd5f8..1d93f1a424 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/CatalogWrapperForREST.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/CatalogWrapperForREST.java@@ -174,6 +174,11 @@ public class CatalogWrapperForREST extends IcebergCatalogWrapper {return catalogConfigToClients;}+ @Override+ protected boolean useDifferentClassLoader() {+ return false;+ }+private LoadTableResponse injectCredentialConfig(TableIdentifier tableIdentifier,LoadTableResponse loadTableResponse,