[Bug] Fix bug that Drop olap table may introduce some problems when table's state is not normal (#5712)

Co-authored-by: caiconghui <caiconghui@xiaomi.com>
This commit is contained in:
caiconghui
2021-05-12 10:38:23 +08:00
committed by GitHub
parent 5fed34fcfe
commit 55ca52a42d

View File

@ -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();