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

   ### What problem does this PR solve?
   
   When an upstream async materialized view refreshes many partitions in 
batches (controlled by `refresh_partition_num`, default `1`), each batch 
executes an `INSERT OVERWRITE` that emits `DataChangeEvent` and 
`ReplacePartitionEvent`. Downstream materialized views configured with `ON 
COMMIT` are triggered immediately on every batch, which can cause downstream 
MVs (especially unpartitioned ones) to rebuild repeatedly while the upstream MV 
refresh is still running.
   
   ### How does this PR solve it?
   
   1. Track active refresh windows per MV in `MTMVService` (`beginRefresh` / 
`finishRefresh`) using a reference-counted state with a `changed` flag.
   2. While an upstream MV is refreshing, `MTMVService.processEvent` records 
`changed = true` and suppresses immediate downstream `ON COMMIT` triggers.
   3. In `MTMVTask.runTask`, call `beginRefresh` after acquiring 
`job.writeLock()`, call `finishRefresh` before releasing `job.writeUnlock()`, 
and if any change occurred during the refresh, call 
`triggerOnCommitAfterRefresh` after releasing the lock to trigger downstream 
`ON COMMIT` MVs once.
   4. Keep direct writes outside a refresh (e.g. with 
`allow_modify_materialized_view_data = true`) triggering immediately as before, 
and catch per-downstream exceptions so one failing downstream MV does not block 
others.
   
   ### Tests
   
   - Unit test: `org.apache.doris.mtmv.MTMVServiceTest`
   - Regression test: 
`regression-test/suites/mtmv_p0/test_chain_on_commit_coalesce.groovy`
   


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