This is an automated email from the ASF dual-hosted git repository.

caiconghui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new ad365b3  [Bug] Fix bug that cannot cancel alter table operation when 
table is unstable (#5998)
ad365b3 is described below

commit ad365b3b64ec4be6fb72f04b0b7df6c6a8ab5989
Author: caiconghui <55968745+caicong...@users.noreply.github.com>
AuthorDate: Wed Jun 9 15:00:17 2021 +0800

    [Bug] Fix bug that cannot cancel alter table operation when table is 
unstable (#5998)
    
    Co-authored-by: caiconghui <caicong...@xiaomi.com>
---
 .../main/java/org/apache/doris/alter/MaterializedViewHandler.java   | 6 +++---
 .../src/main/java/org/apache/doris/alter/SchemaChangeHandler.java   | 5 +++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java 
b/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java
index 6afe586..87c9c70 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java
@@ -1214,7 +1214,7 @@ public class MaterializedViewHandler extends AlterHandler 
{
         }
         olapTable.writeLock();
         try {
-            if (olapTable.getState() != OlapTableState.ROLLUP) {
+            if (olapTable.getState() != OlapTableState.ROLLUP && 
olapTable.getState() != OlapTableState.WAITING_STABLE) {
                 throw new DdlException("Table[" + tableName + "] is not under 
ROLLUP. "
                         + "Use 'ALTER TABLE DROP ROLLUP' if you want to.");
             }
@@ -1232,7 +1232,7 @@ public class MaterializedViewHandler extends AlterHandler 
{
             }
             if (rollupJobV2List.size() == 0) {
                 rollupJob = getAlterJob(olapTable.getId());
-                Preconditions.checkNotNull(rollupJob, olapTable.getId());
+                Preconditions.checkNotNull(rollupJob, "Table[" + tableName + 
"] is not under ROLLUP. ");
                 if (rollupJob.getState() == JobState.FINISHED
                         || rollupJob.getState() == JobState.FINISHING
                         || rollupJob.getState() == JobState.CANCELLED) {
@@ -1244,7 +1244,7 @@ public class MaterializedViewHandler extends AlterHandler 
{
             olapTable.writeUnlock();
         }
 
-        // alter job v2's cancel must be called outside the database lock
+        // alter job v2's cancel must be called outside the table lock
         if (rollupJobV2List.size() != 0) {
             for (AlterJobV2 alterJobV2 : rollupJobV2List) {
                 alterJobV2.cancel("user cancelled");
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java 
b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
index 3a00b62..a109192 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
@@ -1905,7 +1905,8 @@ public class SchemaChangeHandler extends AlterHandler {
         }
         olapTable.writeLock();
         try {
-            if (olapTable.getState() != OlapTableState.SCHEMA_CHANGE) {
+            if (olapTable.getState() != OlapTableState.SCHEMA_CHANGE &&
+                    olapTable.getState() != OlapTableState.WAITING_STABLE) {
                 throw new DdlException("Table[" + tableName + "] is not under 
SCHEMA_CHANGE.");
             }
 
@@ -1915,7 +1916,7 @@ public class SchemaChangeHandler extends AlterHandler {
             schemaChangeJobV2 = schemaChangeJobV2List.size() == 0 ? null : 
Iterables.getOnlyElement(schemaChangeJobV2List);
             if (schemaChangeJobV2 == null) {
                 schemaChangeJob = getAlterJob(olapTable.getId());
-                Preconditions.checkNotNull(schemaChangeJob, olapTable.getId());
+                Preconditions.checkNotNull(schemaChangeJob, "Table[" + 
tableName + "] is not under SCHEMA_CHANGE.");
                 if (schemaChangeJob.getState() == JobState.FINISHING
                         || schemaChangeJob.getState() == JobState.FINISHED
                         || schemaChangeJob.getState() == JobState.CANCELLED) {

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to