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

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


The following commit(s) were added to refs/heads/master by this push:
     new 464d89c5f62 [fix](mtmv) Avoid mutating excluded trigger tables (#62984)
464d89c5f62 is described below

commit 464d89c5f621023af32699e2e772707661af913d
Author: foxtail463 <[email protected]>
AuthorDate: Mon May 11 11:53:30 2026 +0800

    [fix](mtmv) Avoid mutating excluded trigger tables (#62984)
    
    Problem Summary:
    
    isMTMVPartitionSync adds followed PCT tables into the excluded trigger
    table set while checking partition sync. Some callers pass immutable
    sets, such as the force-consistent rewrite path using ImmutableSet.of(),
    so partitioned MTMVs can fail with UnsupportedOperationException before
    the sync check finishes. Copy the input set into a local mutable set
    before adding derived PCT tables, avoiding mutation of caller-owned
    state and supporting immutable inputs.
    
    ---------
    
    Co-authored-by: yangtao555 <[email protected]>
---
 .../java/org/apache/doris/mtmv/MTMVPartitionUtil.java   |  5 +++--
 .../org/apache/doris/mtmv/MTMVPartitionUtilTest.java    | 17 +++++++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPartitionUtil.java 
b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPartitionUtil.java
index 3f8b4aa2ec7..aea97a2dc87 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPartitionUtil.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPartitionUtil.java
@@ -94,6 +94,7 @@ public class MTMVPartitionUtil {
             Set<TableNameInfo> excludedTriggerTables) throws AnalysisException 
{
         MTMV mtmv = refreshContext.getMtmv();
         Map<MTMVRelatedTableIf, Set<String>> partitionMappings = 
refreshContext.getByPartitionName(partitionName);
+        Set<TableNameInfo> excludedTriggerTablesToCheck = 
Sets.newHashSet(excludedTriggerTables);
         if (mtmv.getMvPartitionInfo().getPartitionType() != 
MTMVPartitionType.SELF_MANAGE) {
             if (MapUtils.isEmpty(partitionMappings)) {
                 LOG.warn("can not found pct partition, partitionName: {}, 
mtmvName: {}",
@@ -104,7 +105,7 @@ public class MTMVPartitionUtil {
             for (MTMVRelatedTableIf pctTable : pctTables) {
                 Set<String> relatedPartitionNames = 
partitionMappings.getOrDefault(pctTable, Sets.newHashSet());
                 // if follow base table, not need compare with related table, 
only should compare with related partition
-                excludedTriggerTables.add(TableNameInfoUtils.fromCatalogDb(
+                
excludedTriggerTablesToCheck.add(TableNameInfoUtils.fromCatalogDb(
                         pctTable.getDatabase().getCatalog(),
                         pctTable.getDatabase(), pctTable));
                 if (!isSyncWithPartitions(refreshContext, partitionName, 
relatedPartitionNames, pctTable)) {
@@ -114,7 +115,7 @@ public class MTMVPartitionUtil {
 
         }
         return isSyncWithAllBaseTables(refreshContext, partitionName, tables,
-                excludedTriggerTables);
+                excludedTriggerTablesToCheck);
 
     }
 
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/mtmv/MTMVPartitionUtilTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/mtmv/MTMVPartitionUtilTest.java
index 43f90595a63..41ca743e76a 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/mtmv/MTMVPartitionUtilTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/mtmv/MTMVPartitionUtilTest.java
@@ -28,6 +28,7 @@ import org.apache.doris.common.AnalysisException;
 import org.apache.doris.datasource.CatalogIf;
 import org.apache.doris.mtmv.MTMVPartitionInfo.MTMVPartitionType;
 
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
@@ -171,6 +172,22 @@ public class MTMVPartitionUtilTest {
         Assert.assertFalse(isSyncWithPartition);
     }
 
+    @Test
+    public void testIsMTMVPartitionSyncWithImmutableExcludedTriggerTables() 
throws AnalysisException {
+        Map<MTMVRelatedTableIf, Set<String>> partitionMappings = 
Maps.newHashMap();
+        partitionMappings.put(baseOlapTable, Sets.newHashSet("name2"));
+        
Mockito.when(context.getByPartitionName("name1")).thenReturn(partitionMappings);
+        
Mockito.when(mtmvPartitionInfo.getPartitionType()).thenReturn(MTMVPartitionType.FOLLOW_BASE_TABLE);
+        
Mockito.when(mtmvPartitionInfo.getPctTables()).thenReturn(Sets.newHashSet(baseOlapTable));
+
+        Set<TableNameInfo> excludedTriggerTables = ImmutableSet.of();
+        boolean isMTMVPartitionSync = 
MTMVPartitionUtil.isMTMVPartitionSync(context, "name1", baseTables,
+                excludedTriggerTables);
+
+        Assert.assertTrue(isMTMVPartitionSync);
+        Assert.assertTrue(excludedTriggerTables.isEmpty());
+    }
+
     @Test
     public void testGeneratePartitionName() {
         List<List<PartitionValue>> inValues = Lists.newArrayList();


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

Reply via email to