seawinde opened a new pull request, #64041:
URL: https://github.com/apache/doris/pull/64041

   ### What problem does this PR solve?
   
   Issue Number: N/A
   
   Related PR: N/A
   
   Problem Summary:
   Changing the effective `excluded_trigger_tables` set changes which base 
tables participate in MTMV freshness decisions. Reusing the old 
`refreshSnapshot` can make a later AUTO refresh skip work under the new exclude 
rules, leaving MV data based on the old snapshot.
   
   Root cause: In `MTMVTask.calculateNeedRefreshPartitions()`, AUTO refresh 
calls `MTMVPartitionUtil.isMTMVSync()` before verifying whether the refresh 
baseline is still complete. After `ALTER MATERIALIZED VIEW ... SET 
("excluded_trigger_tables"=...)`, the new exclude rules can skip changed base 
tables and incorrectly mark the MV as fresh.
   
   | File | Change Description |
   |------|-------------------|
   | `MTMV.java` | Detect effective `excluded_trigger_tables` set changes, bump 
`schemaChangeVersion`, and clear `refreshSnapshot` without setting 
`MTMVStatus.state` to `SCHEMA_CHANGE`. |
   | `MTMVTask.java` | Treat incomplete refresh snapshots as requiring a 
complete AUTO refresh before calling `isMTMVSync()`. Manual specified-partition 
refresh keeps existing behavior. |
   | `MTMVTest.java` | Cover qualified-name changes, same-set order changes, 
reduced/cleared excluded table sets, and unrelated property changes. |
   | `MTMVTaskTest.java` | Cover incomplete-baseline AUTO refresh and manual 
specified-partition behavior. |
   | `test_excluded_trigger_table_mtmv.groovy` | Align the case comments with 
the expected refresh behavior. |
   
   Design rationale:
   This uses the existing `refreshSnapshot` completeness as the 
invalid-baseline signal instead of adding a new persisted flag. That keeps the 
change scoped to the ALTER property path and AUTO refresh decision path. Query 
rewrite behavior is unchanged.
   
   ```mermaid
   graph TD
       A[ALTER excluded_trigger_tables] --> B[Compare effective table-name set]
       B -->|changed| C[Clear refreshSnapshot]
       C --> D[Next AUTO refresh]
       D --> E{refreshSnapshot complete?}
       E -->|No| F[Refresh all MV partitions]
       E -->|Yes| G[Run isMTMVSync with current exclude rules]
   ```
   
   ### Release note
   
   Changing `excluded_trigger_tables` on an MTMV now invalidates the refresh 
baseline so the next AUTO refresh rebuilds it with a complete refresh.
   
   ### Check List (For Author)
   
   - Test
       - [ ] Regression test
       - [x] 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
   
   `./run-fe-ut.sh --run 
org.apache.doris.mtmv.MTMVTest,org.apache.doris.mtmv.MTMVTaskTest`
   
   Regression test was not run locally because no FE/BE cluster is available to 
generate the updated `.out` file.
   
   - Behavior changed:
       - [ ] No.
       - [x] Yes. `ALTER MATERIALIZED VIEW ... SET 
("excluded_trigger_tables"=...)` now invalidates the refresh baseline when the 
effective excluded table set changes. The next AUTO refresh performs a complete 
refresh if the baseline is incomplete.
   
   - Does this need documentation?
       - [x] No.
       - [ ] Yes.
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to