diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java index 09e2ae350c5e98..4f205be0381b37 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java @@ -93,7 +93,7 @@ public class Database extends MetaObject implements Writable, DatabaseIf, private final Map idToTable; private ConcurrentMap nameToTable; // table name lower case -> table name - private final Map lowerCaseToTableName; + private final ConcurrentMap lowerCaseToTableName; // user define function @SerializedName(value = "name2Function") diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java index 3a9e96bade67f5..18f2e333e9119b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java @@ -441,8 +441,17 @@ public void createDb(CreateDbStmt stmt) throws DdlException { ErrorReport.reportDdlException(ErrorCode.ERR_DB_CREATE_EXISTS, fullDbName); } } else { - unprotectCreateDb(db); - Env.getCurrentEnv().getEditLog().logCreateDb(db); + if (!db.tryWriteLock(100, TimeUnit.SECONDS)) { + LOG.warn("try lock failed, create database failed {}", fullDbName); + ErrorReport.reportDdlException(ErrorCode.ERR_EXECUTE_TIMEOUT, + "create database " + fullDbName + " time out"); + } + try { + unprotectCreateDb(db); + Env.getCurrentEnv().getEditLog().logCreateDb(db); + } finally { + db.writeUnlock(); + } } } finally { unlock();