This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 9533bd3e8b0 branch-2.1: (fix)[db] Fix create database and create table
data race #44600 (#44683)
9533bd3e8b0 is described below
commit 9533bd3e8b094f7bf2bfc199d001f2a19012a971
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Nov 29 20:50:10 2024 +0800
branch-2.1: (fix)[db] Fix create database and create table data race #44600
(#44683)
Cherry-picked from #44600
Co-authored-by: deardeng <[email protected]>
---
.../src/main/java/org/apache/doris/catalog/Database.java | 2 +-
.../java/org/apache/doris/datasource/InternalCatalog.java | 13 +++++++++++--
2 files changed, 12 insertions(+), 3 deletions(-)
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 df01f6562de..50a0367dfec 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
@@ -91,7 +91,7 @@ public class Database extends MetaObject implements Writable,
DatabaseIf<Table>
@SerializedName(value = "nameToTable")
private Map<String, Table> nameToTable;
// table name lower case -> table name
- private final Map<String, String> lowerCaseToTableName;
+ private final ConcurrentMap<String, String> 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 aab70f86733..70a9cffe78d 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
@@ -432,8 +432,17 @@ public class InternalCatalog implements
CatalogIf<Database> {
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();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]