diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java index 6fcd495b67f3b1..c5408dd3103852 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java @@ -104,6 +104,10 @@ public abstract class ExternalCatalog private ExternalSchemaCache schemaCache; private String comment; + // A cached and being converted properties for external catalog. + // generated from catalog properties. + private byte[] propLock = new byte[0]; + private Map convertedProperties = null; public ExternalCatalog() { } @@ -298,6 +302,9 @@ protected void init() { public void onRefresh(boolean invalidCache) { this.objectCreated = false; this.initialized = false; + synchronized (this.propLock) { + this.convertedProperties = null; + } this.invalidCacheInInit = invalidCache; if (invalidCache) { Env.getCurrentEnv().getExtMetaCacheMgr().invalidateCatalogCache(id); @@ -421,7 +428,17 @@ public List getDbIds() { @Override public Map getProperties() { - return PropertyConverter.convertToMetaProperties(catalogProperty.getProperties()); + // convert properties may be a heavy operation, so we cache the result. + if (convertedProperties != null) { + return convertedProperties; + } + synchronized (propLock) { + if (convertedProperties != null) { + return convertedProperties; + } + convertedProperties = PropertyConverter.convertToMetaProperties(catalogProperty.getProperties()); + return convertedProperties; + } } @Override @@ -552,6 +569,7 @@ public void gsonPostProcess() throws IOException { } } } + this.propLock = new byte[0]; } public void addDatabaseForTest(ExternalDatabase db) { diff --git a/fe/fe-core/src/test/java/org/apache/doris/datasource/jdbc/JdbcExternalCatalogTest.java b/fe/fe-core/src/test/java/org/apache/doris/datasource/jdbc/JdbcExternalCatalogTest.java index 7bc268b64211bb..8394daf0682b6c 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/datasource/jdbc/JdbcExternalCatalogTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/datasource/jdbc/JdbcExternalCatalogTest.java @@ -54,6 +54,7 @@ public void replayJdbcCatalogTest() throws DdlException { Map newProperties = Maps.newHashMap(); newProperties.put(JdbcResource.CONNECTION_POOL_MIN_SIZE, "2"); jdbcExternalCatalog.getCatalogProperty().modifyCatalogProps(newProperties); + jdbcExternalCatalog.notifyPropertiesUpdated(newProperties); JdbcExternalCatalog replayJdbcCatalog2 = (JdbcExternalCatalog) CatalogFactory.createFromLog( jdbcExternalCatalog.constructEditLog()); Map properties2 = replayJdbcCatalog2.getProperties();