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

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new ace284b2199 branch-2.1: [bug](group commit) Fix group commit blocked 
after schema change throw exception (#55684)
ace284b2199 is described below

commit ace284b219913570da411599da9785cd882be55e
Author: xy720 <[email protected]>
AuthorDate: Sat Sep 6 00:11:11 2025 +0800

    branch-2.1: [bug](group commit) Fix group commit blocked after schema 
change throw exception (#55684)
    
    ### What problem does this PR solve?
    
    pick #54113 #55132
    
    ### Check List (For Author)
    
    - Test <!-- At least one of them must be included. -->
        - [x] Regression test
        - [ ] Unit Test
        - [ ] Manual test (add detailed scripts or steps below)
        - [ ] No need to test or manual test. Explain why:
    - [ ] This is a refactor/code format and no logic has been changed.
            - [ ] Previous test can cover this change.
            - [ ] No code files have been changed.
            - [ ] Other reason <!-- Add your reason?  -->
    
    - Behavior changed:
        - [x] No.
        - [ ] Yes. <!-- Explain the behavior change -->
    
    - Does this need documentation?
        - [x] No.
    - [ ] Yes. <!-- Add document PR link here. eg:
    https://github.com/apache/doris-website/pull/1214 -->
    
    ### Check List (For Reviewer who merge this PR)
    
    - [ ] Confirm the release note
    - [ ] Confirm test cases
    - [ ] Confirm document
    - [ ] Add branch pick label <!-- Add branch pick label that this PR
    should merge into -->
---
 .../apache/doris/alter/MaterializedViewHandler.java   | 19 +++++++++++++++++++
 .../suites/insert_p0/insert_group_commit_into.groovy  | 17 +++++++++++++++++
 2 files changed, 36 insertions(+)

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 9623ef562d2..c847688bca4 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
@@ -158,6 +158,10 @@ public class MaterializedViewHandler extends AlterHandler {
             if (tableNotFinalStateJobIdset == null) {
                 // This could happen when this job is already removed before.
                 // return false, so that we will not set table's to NORMAL 
again.
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("alter job is already removed before. tableId: 
{}, jobId: {}",
+                            tableId, jobId);
+                }
                 return false;
             }
             tableNotFinalStateJobIdset.remove(jobId);
@@ -223,6 +227,11 @@ public class MaterializedViewHandler extends AlterHandler {
             Env.getCurrentEnv().getEditLog().logAlterJob(rollupJobV2);
             LOG.info("finished to create materialized view job: {}", 
rollupJobV2.getJobId());
         } finally {
+            if (olapTable.getState() != OlapTableState.ROLLUP) {
+                // state is not ROLLUP, means encountered some exception 
before jobs submitted,
+                // so we need to unblock table here.
+                
Env.getCurrentEnv().getGroupCommitManager().unblockTable(olapTable.getId());
+            }
             olapTable.writeUnlock();
         }
     }
@@ -326,6 +335,11 @@ public class MaterializedViewHandler extends AlterHandler {
             }
             throw e;
         } finally {
+            if (olapTable.getState() != OlapTableState.ROLLUP) {
+                // state is not ROLLUP, means encountered some exception 
before jobs submitted,
+                // so we need to unblock table here.
+                
Env.getCurrentEnv().getGroupCommitManager().unblockTable(olapTable.getId());
+            }
             olapTable.writeUnlock();
         }
     }
@@ -1182,6 +1196,11 @@ public class MaterializedViewHandler extends 
AlterHandler {
             changeTableStatus(alterJob.getDbId(), alterJob.getTableId(), 
OlapTableState.NORMAL);
             LOG.info("set table's state to NORMAL, table id: {}, job id: {}", 
alterJob.getTableId(),
                     alterJob.getJobId());
+        } else {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Failed to remove job from tableNotFinalStateJobMap, 
table id: {}, job id: {}",
+                        alterJob.getTableId(), alterJob.getJobId());
+            }
         }
     }
 
diff --git a/regression-test/suites/insert_p0/insert_group_commit_into.groovy 
b/regression-test/suites/insert_p0/insert_group_commit_into.groovy
index 4d43c38f149..59cd40e7d6d 100644
--- a/regression-test/suites/insert_p0/insert_group_commit_into.groovy
+++ b/regression-test/suites/insert_p0/insert_group_commit_into.groovy
@@ -242,6 +242,23 @@ suite("insert_group_commit_into") {
                 def rowCount = sql "select count(*) from ${table}"
                 logger.info("row count: " + rowCount)
                 assertEquals(rowCount[0][0], 23)
+
+                // 8. Test create rollup throw exception and group commit 
behavior
+                try {
+                    sql """ alter table ${table} ADD ROLLUP r1(name, score); 
"""
+                    assertTrue(false, "create rollup with duplicate name 
should fail.")
+                } catch (Exception e) {
+                    logger.info("Expected create rollup error: " + 
e.getMessage())
+                    assertTrue(e.getMessage().contains("already exists"))
+                }
+
+                group_commit_insert_with_retry """ insert into ${table}(id, 
name) values(2, 'b');  """, 1
+                group_commit_insert_with_retry """ insert into ${table}(id) 
values(6); """, 1
+                getRowCount(25)
+
+                // Verify group commit works after add rollup throw exception
+                group_commit_insert """ insert into ${table}(id, name) 
values(2, 'b'); """, 1
+                getRowCount(26)
             }
         } finally {
             // try_sql("DROP TABLE ${table}")


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to