This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.1 by this push:
new 021ceb984f9 branch-3.1: [fix](database) Fix `insert into` race with
`drop table` #55264 (#55348)
021ceb984f9 is described below
commit 021ceb984f92325894ee57572f212981c1114a9f
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Aug 27 17:43:12 2025 +0800
branch-3.1: [fix](database) Fix `insert into` race with `drop table` #55264
(#55348)
Cherry-picked from #55264
Co-authored-by: deardeng <[email protected]>
---
.../src/main/java/org/apache/doris/catalog/Database.java | 12 +++---------
.../main/java/org/apache/doris/common/proc/DbsProcDir.java | 2 +-
.../java/org/apache/doris/datasource/InternalCatalog.java | 2 +-
.../org/apache/doris/transaction/DatabaseTransactionMgr.java | 2 +-
.../doris/transaction/DbUsedDataQuotaInfoCollector.java | 2 +-
5 files changed, 7 insertions(+), 13 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 70814dbbd98..1fb6cd28d6b 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
@@ -316,20 +316,14 @@ public class Database extends MetaObject implements
Writable, DatabaseIf<Table>,
}
}
- public long getUsedDataQuotaWithLock() {
+ public long getUsedDataQuota() {
return getUsedDataSize().first;
}
public Pair<Long, Long> getUsedDataSize() {
long usedDataSize = 0;
long usedRemoteDataSize = 0;
- List<Table> tables = new ArrayList<>();
- readLock();
- try {
- tables.addAll(this.idToTable.values());
- } finally {
- readUnlock();
- }
+ List<Table> tables = new ArrayList<>(this.idToTable.values());
for (Table table : tables) {
if (!table.isManagedTable()) {
@@ -371,7 +365,7 @@ public class Database extends MetaObject implements
Writable, DatabaseIf<Table>,
Pair<Double, String> quotaUnitPair =
DebugUtil.getByteUint(dataQuotaBytes);
String readableQuota =
DebugUtil.DECIMAL_FORMAT_SCALE_3.format(quotaUnitPair.first) + " "
+ quotaUnitPair.second;
- long usedDataQuota = getUsedDataQuotaWithLock();
+ long usedDataQuota = getUsedDataQuota();
long leftDataQuota = Math.max(dataQuotaBytes - usedDataQuota, 0);
Pair<Double, String> leftQuotaUnitPair =
DebugUtil.getByteUint(leftDataQuota);
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/common/proc/DbsProcDir.java
b/fe/fe-core/src/main/java/org/apache/doris/common/proc/DbsProcDir.java
index 5a4fb3460ae..bd9e3e9c736 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/proc/DbsProcDir.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/proc/DbsProcDir.java
@@ -107,7 +107,7 @@ public class DbsProcDir implements ProcDirInterface {
dbInfo.add(dbName);
dbInfo.add(tableNum);
- long usedDataQuota = (db instanceof Database) ? ((Database)
db).getUsedDataQuotaWithLock() : 0;
+ long usedDataQuota = (db instanceof Database) ? ((Database)
db).getUsedDataQuota() : 0;
long dataQuota = (db instanceof Database) ? ((Database)
db).getDataQuota() : 0;
String readableUsedQuota =
DebugUtil.printByteWithUnit(usedDataQuota);
String readableQuota = DebugUtil.printByteWithUnit(dataQuota);
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 08ad1e357ce..3b057edab91 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
@@ -3985,7 +3985,7 @@ public class InternalCatalog implements
CatalogIf<Database> {
public Map<String, Long> getUsedDataQuota() {
Map<String, Long> dbToDataSize = new TreeMap<>();
for (Database db : this.idToDb.values()) {
- dbToDataSize.put(db.getFullName(), db.getUsedDataQuotaWithLock());
+ dbToDataSize.put(db.getFullName(), db.getUsedDataQuota());
}
return dbToDataSize;
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/transaction/DatabaseTransactionMgr.java
b/fe/fe-core/src/main/java/org/apache/doris/transaction/DatabaseTransactionMgr.java
index c1d8018e616..6263b48fabe 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/transaction/DatabaseTransactionMgr.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/transaction/DatabaseTransactionMgr.java
@@ -384,7 +384,7 @@ public class DatabaseTransactionMgr {
Database db = env.getInternalCatalog().getDbOrMetaException(dbId);
if (usedQuotaDataBytes == -1) {
- usedQuotaDataBytes = db.getUsedDataQuotaWithLock();
+ usedQuotaDataBytes = db.getUsedDataQuota();
}
long dataQuotaBytes = db.getDataQuota();
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/transaction/DbUsedDataQuotaInfoCollector.java
b/fe/fe-core/src/main/java/org/apache/doris/transaction/DbUsedDataQuotaInfoCollector.java
index f03da231b9b..3a85c75d284 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/transaction/DbUsedDataQuotaInfoCollector.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/transaction/DbUsedDataQuotaInfoCollector.java
@@ -55,7 +55,7 @@ public class DbUsedDataQuotaInfoCollector extends
MasterDaemon {
continue;
}
try {
- long usedDataQuotaBytes = db.getUsedDataQuotaWithLock();
+ long usedDataQuotaBytes = db.getUsedDataQuota();
globalTransactionMgr.updateDatabaseUsedQuotaData(dbId,
usedDataQuotaBytes);
if (LOG.isDebugEnabled()) {
LOG.debug("Update database[{}] used data quota bytes :
{}.", db.getFullName(), usedDataQuotaBytes);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]