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

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


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new e79398ab15b branch-3.0: [fix](mtmv)The refresh method for MTMV is 
commit. If the status is PAUSED, no more tasks should be generated #46020 
(#46264)
e79398ab15b is described below

commit e79398ab15b4cbd381b9cb0a35623d97a6fcca39
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Mon Jan 6 12:00:11 2025 +0800

    branch-3.0: [fix](mtmv)The refresh method for MTMV is commit. If the status 
is PAUSED, no more tasks should be generated #46020 (#46264)
    
    Cherry-picked from #46020
    
    Co-authored-by: zhangdong <zhangd...@selectdb.com>
---
 .../java/org/apache/doris/mtmv/MTMVJobManager.java |  7 ++++++
 regression-test/data/mtmv_p0/test_commit_mtmv.out  | 25 +++++++++++++++++++++-
 .../suites/mtmv_p0/test_commit_mtmv.groovy         | 24 ++++++++++++++++++++-
 3 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobManager.java 
b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobManager.java
index a9dee132f64..7ea3d9dc05f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobManager.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobManager.java
@@ -213,6 +213,13 @@ public class MTMVJobManager implements MTMVHookService {
 
     public void onCommit(MTMV mtmv) throws DdlException, JobException {
         MTMVJob job = getJobByMTMV(mtmv);
+        if (!job.getJobStatus().equals(JobStatus.RUNNING)) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("job status of async materialized view: [{}] is: 
[{}], ignore this event.", mtmv.getName(),
+                        job.getJobStatus());
+            }
+            return;
+        }
         MTMVTaskContext mtmvTaskContext = new 
MTMVTaskContext(MTMVTaskTriggerMode.COMMIT, Lists.newArrayList(),
                 false);
         Env.getCurrentEnv().getJobManager().triggerJob(job.getJobId(), 
mtmvTaskContext);
diff --git a/regression-test/data/mtmv_p0/test_commit_mtmv.out 
b/regression-test/data/mtmv_p0/test_commit_mtmv.out
index 8c96733d214..433d55ef4b8 100644
--- a/regression-test/data/mtmv_p0/test_commit_mtmv.out
+++ b/regression-test/data/mtmv_p0/test_commit_mtmv.out
@@ -15,16 +15,39 @@
 -- !task2 --
 {"triggerMode":"COMMIT","partitions":[],"isComplete":false}
 
--- !mv1_2 --
+-- !mv1_pause --
 1      2017-01-15      1
+2      2017-02-15      2
+3      2017-03-15      3
+
+-- !mv1_resume --
+1      2017-01-15      1
+2      2017-02-15      2
+3      2017-03-15      3
+4      2017-01-15      4
+5      2017-01-15      5
+
+-- !mv2_resume --
+1      2017-01-15      1
+2      2017-02-15      2
+3      2017-03-15      3
+4      2017-01-15      4
+5      2017-01-15      5
+
+-- !mv1_2 --
 1      2017-01-15      1
 2      2017-02-15      2
 3      2017-03-15      3
+4      2017-01-15      4
+5      2017-01-15      5
+6      2017-01-15      6
 
 -- !mv2_2 --
 1      2017-01-15      1
 2      2017-02-15      2
 3      2017-03-15      3
+4      2017-01-15      4
+5      2017-01-15      5
 
 -- !mv1_init --
 1      2017-01-15      1
diff --git a/regression-test/suites/mtmv_p0/test_commit_mtmv.groovy 
b/regression-test/suites/mtmv_p0/test_commit_mtmv.groovy
index dac1d5c22cd..bb4c3f8f7ce 100644
--- a/regression-test/suites/mtmv_p0/test_commit_mtmv.groovy
+++ b/regression-test/suites/mtmv_p0/test_commit_mtmv.groovy
@@ -64,13 +64,35 @@ suite("test_commit_mtmv") {
     order_qt_mv2 "SELECT * FROM ${mvName2}"
     order_qt_task2 "SELECT TaskContext from tasks('type'='mv') where 
MvName='${mvName2}' order by CreateTime desc limit 1"
 
+    // PAUSE MTMV should not refresh
+    sql """
+        PAUSE MATERIALIZED VIEW JOB ON ${mvName1};
+        """
+     sql """
+         insert into ${tableName} values(4,"2017-01-15",4);
+     """
+    waitingMTMVTaskFinished(jobName1)
+    order_qt_mv1_pause "SELECT * FROM ${mvName1}"
+
+    // resume MTMV should refresh
+    sql """
+        RESUME MATERIALIZED VIEW JOB ON ${mvName1};
+        """
+     sql """
+         insert into ${tableName} values(5,"2017-01-15",5);
+     """
+    waitingMTMVTaskFinished(jobName1)
+    order_qt_mv1_resume "SELECT * FROM ${mvName1}"
+    waitingMTMVTaskFinished(jobName2)
+    order_qt_mv2_resume "SELECT * FROM ${mvName2}"
+
     // on manual can not trigger by commit
     sql """
             alter MATERIALIZED VIEW ${mvName2} REFRESH ON MANUAL;
         """
 
      sql """
-          insert into ${tableName} values(1,"2017-01-15",1);;
+          insert into ${tableName} values(6,"2017-01-15",6);;
       """
     waitingMTMVTaskFinished(jobName1)
     order_qt_mv1_2 "SELECT * FROM ${mvName1}"


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

Reply via email to