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

dataroaring 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 b89cfe149cb branch-3.0: [fix](mtmv)The change to the 
max_persistence_task_count configuration applies retroactively to existing MTMV 
#50537 (#50626)
b89cfe149cb is described below

commit b89cfe149cbe85b4839b02ef26b699264c9dc980
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed May 14 09:46:52 2025 +0800

    branch-3.0: [fix](mtmv)The change to the max_persistence_task_count 
configuration applies retroactively to existing MTMV #50537 (#50626)
    
    Cherry-picked from #50537
    
    Co-authored-by: zhangdong <[email protected]>
---
 .../java/org/apache/doris/mtmv/MTMVJobInfo.java    |  2 +-
 .../org/apache/doris/mtmv/MTMVJobInfoTest.java     | 45 ++++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobInfo.java 
b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobInfo.java
index eb79c30adf5..54dc1577f78 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobInfo.java
@@ -47,7 +47,7 @@ public class MTMVJobInfo {
             return;
         }
         historyTasks.add(task);
-        if (historyTasks.size() > Config.max_persistence_task_count) {
+        while (historyTasks.size() > Config.max_persistence_task_count) {
             historyTasks.poll();
         }
     }
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/mtmv/MTMVJobInfoTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/mtmv/MTMVJobInfoTest.java
new file mode 100644
index 00000000000..82257881fbf
--- /dev/null
+++ b/fe/fe-core/src/test/java/org/apache/doris/mtmv/MTMVJobInfoTest.java
@@ -0,0 +1,45 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.mtmv;
+
+import org.apache.doris.common.Config;
+import org.apache.doris.job.extensions.mtmv.MTMVTask;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MTMVJobInfoTest {
+
+    @Test
+    public void testAddHistoryTask() {
+        int originalCount = Config.max_persistence_task_count;
+        Config.max_persistence_task_count = 0;
+        MTMVJobInfo jobInfo = new MTMVJobInfo("dummyJob");
+        jobInfo.addHistoryTask(new MTMVTask());
+        Assert.assertEquals(0, jobInfo.getHistoryTasks().size());
+        Config.max_persistence_task_count = 2;
+        for (int i = 0; i < 3; i++) {
+            jobInfo.addHistoryTask(new MTMVTask());
+        }
+        Assert.assertEquals(2, jobInfo.getHistoryTasks().size());
+        Config.max_persistence_task_count = 1;
+        jobInfo.addHistoryTask(new MTMVTask());
+        Assert.assertEquals(1, jobInfo.getHistoryTasks().size());
+        Config.max_persistence_task_count = originalCount;
+    }
+}


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

Reply via email to