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

   ### What problem does this PR solve?
   
   Problem Summary:
   
   `RelationImpliedPredicateTest` simulates a successful MV refresh by raising 
the visible version of the MV partitions, so that rewrite normalization does 
not treat the MV scan as empty. However, a materialized view created with 
`BUILD IMMEDIATE` refreshes asynchronously, and a complete refresh uses `INSERT 
OVERWRITE`, which replaces the MV partition and resets its visible version to 
the initial value.
   
   When the refresh task finished after the test had raised the version, the 
test observed a partition with the initial visible version again. During 
pre-rewrite, the candidate plans are replayed with only `ADD_DEFAULT_LIMIT` 
disabled, so `PRUNE_EMPTY_PARTITION` is still enabled and rewrote the MV scan 
into an empty relation. The lower MV then looked "rewritten but not chosen" 
because its cost was near zero, and the upper MV could not be rewritten ("the 
graph logic between query and view is not consistent"). This only showed up on 
loaded CI runners, where the asynchronous refresh often finished after the mock.
   
   The fix waits for the initial `BUILD IMMEDIATE` refresh task to reach a 
final status before mocking the refreshed state. The refresh task updates the 
MV state, snapshots and history under the MV write lock, and the mock path also 
takes the same lock when invalidating the rewrite cache, so once the task is 
finished a late refresh can no longer overwrite the mocked data version. The 
MVs in this test class are refreshed `ON MANUAL`, so the initial task is the 
only one that can replace the partitions.
   
   ### Release note
   
   None
   
   ### Check List (For Author)
   
   - Test: Unit Test
       - 
`RelationImpliedPredicateTest#testNestedMvRewriteAfterPredicateColumnIsProjectedOut`
       - `RelationImpliedPredicateTest` (all 12 cases)
       - Also verified with the refresh task forced to finish after the mock 
(removing the post-create wait in the test helper), which failed 
deterministically before the fix and passes after it
   - Behavior changed: No (test-only change)
   - Does this need documentation: No
   


-- 
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