From 55ca52a42d34047ed39bcc8edaa0ddccd8548989 Mon Sep 17 00:00:00 2001 From: caiconghui <55968745+caiconghui@users.noreply.github.com> Date: Wed, 12 May 2021 10:38:23 +0800 Subject: [PATCH] [Bug] Fix bug that Drop olap table may introduce some problems when table's state is not normal (#5712) Co-authored-by: caiconghui --- .../src/main/java/org/apache/doris/catalog/Catalog.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java index b1a252dce0..2c87f005df 100755 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java @@ -4437,6 +4437,14 @@ public class Catalog { DropInfo info = new DropInfo(db.getId(), table.getId(), -1L, stmt.isForceDrop()); table.writeLock(); try { + if (table instanceof OlapTable && !stmt.isForceDrop()) { + OlapTable olapTable = (OlapTable) table; + if ((olapTable.getState() != OlapTableState.NORMAL)) { + throw new DdlException("The table [" + tableName +"]'s state is " + olapTable.getState() + ", cannot be dropped." + + " please cancel the operation on olap table firstly. If you want to forcibly drop(cannot be recovered)," + + " please use \"DROP table FORCE\"."); + } + } unprotectDropTable(db, table, stmt.isForceDrop(), false); } finally { table.writeUnlock();