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 2aef3075e73 branch-3.1: [fix](temptable) remove temptable name from db
#55084 (#55258)
2aef3075e73 is described below
commit 2aef3075e739669c53d33b89caea41d489a3499a
Author: Yongqiang YANG <[email protected]>
AuthorDate: Tue Aug 26 08:59:46 2025 +0800
branch-3.1: [fix](temptable) remove temptable name from db #55084 (#55258)
picked from #55084
---
.../java/org/apache/doris/catalog/CatalogRecycleBin.java | 5 ++++-
.../src/main/java/org/apache/doris/catalog/Database.java | 12 ++++++++++--
.../java/org/apache/doris/datasource/InternalCatalog.java | 10 +++++++++-
.../suites/alter_p2/test_alter_colocate_group.groovy | 2 +-
4 files changed, 24 insertions(+), 5 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/catalog/CatalogRecycleBin.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/CatalogRecycleBin.java
index b5899435343..019ec290a1d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/CatalogRecycleBin.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/CatalogRecycleBin.java
@@ -144,7 +144,10 @@ public class CatalogRecycleBin extends MasterDaemon
implements Writable, GsonPos
}
// db should be empty. all tables are recycled before
- Preconditions.checkState(db.getTables().isEmpty());
+ if (!db.getTableIds().isEmpty()) {
+ throw new IllegalStateException("Database " + db.getFullName() + "
is not empty. Contains tables: "
+ +
db.getTableIds().stream().collect(Collectors.toSet()));
+ }
// recycle db
RecycleDatabaseInfo databaseInfo = new RecycleDatabaseInfo(db,
tableNames, tableIds);
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 a2089fac133..70814dbbd98 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
@@ -479,9 +479,17 @@ public class Database extends MetaObject implements
Writable, DatabaseIf<Table>,
tableName = tableName.toLowerCase();
}
Table table = getTableNullable(tableName);
+ if (table == null) {
+ return;
+ }
+ unregisterTable(table.getId());
+ }
+
+ public void unregisterTable(Long tableId) {
+ Table table = getTableNullable(tableId);
if (table != null) {
- this.nameToTable.remove(tableName);
- this.lowerCaseToTableName.remove(tableName.toLowerCase());
+ this.nameToTable.remove(table.getName());
+ this.lowerCaseToTableName.remove(table.getName().toLowerCase());
this.idToTable.remove(table.getId());
if (table.isTemporary()) {
Env.getCurrentEnv().unregisterTempTable(table);
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 bf8d1d47e85..08ad1e357ce 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
@@ -575,6 +575,14 @@ public class InternalCatalog implements
CatalogIf<Database> {
for (Table table : db.getTables()) {
unprotectDropTable(db, table, isForeDrop, isReplay, recycleTime);
}
+ if (!db.getTables().isEmpty()) {
+ throw new IllegalStateException("Database " + db.getFullName() + "
is not empty. Contains tables: "
+ +
db.getTableIds().stream().collect(Collectors.toSet()));
+ }
+ if (!db.getTableNames().isEmpty()) {
+ throw new IllegalStateException("Database " + db.getFullName() + "
is not empty. Contains tables: "
+ +
db.getTableNames().stream().collect(Collectors.toSet()));
+ }
db.markDropped();
}
@@ -1044,7 +1052,7 @@ public class InternalCatalog implements
CatalogIf<Database> {
}
Env.getCurrentEnv().getAnalysisManager().removeTableStats(table.getId());
- db.unregisterTable(table.getName());
+ db.unregisterTable(table.getId());
StopWatch watch = StopWatch.createStarted();
Env.getCurrentRecycleBin().recycleTable(db.getId(), table, isReplay,
isForceDrop, recycleTime);
watch.stop();
diff --git a/regression-test/suites/alter_p2/test_alter_colocate_group.groovy
b/regression-test/suites/alter_p2/test_alter_colocate_group.groovy
index 848f4146dcc..3b8aa406865 100644
--- a/regression-test/suites/alter_p2/test_alter_colocate_group.groovy
+++ b/regression-test/suites/alter_p2/test_alter_colocate_group.groovy
@@ -134,8 +134,8 @@ suite ("test_alter_colocate_group") {
def checkTableReplicaAlloc = { tableName, hasDynamicPart, replicaNum ->
def result = sql """ show create table ${tableName} """
def createTbl = result[0][1].toString()
- assertTrue(createTbl.indexOf("\"replication_allocation\" =
\"tag.location.default: ${replicaNum}\"") > 0)
log.info("createTbl: ${createTbl}")
+ assertTrue(createTbl.indexOf("\"replication_allocation\" =
\"tag.location.default: ${replicaNum}\"") > 0)
if (hasDynamicPart) {
assertTrue(createTbl.indexOf(
"\"dynamic_partition.replication_allocation\" =
\"tag.location.default: ${replicaNum}\"") > 0)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]