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

   ### What problem does this PR solve?
   
   Related issue: https://github.com/apache/doris/issues/65418
   
   Problem Summary:
   
   An incremental materialized view whose base table carries a BIGINT sequence 
column (`function_column.sequence_col`) can silently drop an updated row. After 
an `UPDATE` on a base table and an `INCREMENTAL` refresh, the refresh task 
reports SUCCESS, but the row is left with `__DORIS_DELETE_SIGN__ = 1` and 
disappears; a later `INCREMENTAL` refresh cannot restore it.
   
   Root cause: the snapshot-side base `OlapScan` leaks its own hidden 
`__DORIS_SEQUENCE_COL__` into the normalized join plan. When the delta side is 
the RIGHT child of a join, the leaked base sequence appears before the 
delta-allocated one, so the merge-on-write merge binds the base value and the 
delete sign wins.
   
   Fix: `IvmNormalizeUniqKeysMTMV` now also drops the base table's 
`__DORIS_SEQUENCE_COL__` from the base scan output, next to the existing IVM 
hidden columns. Only the sequence column needs masking: the base delete sign, 
version and commit tso are recomputed by the plan (and pruned when unused), and 
the base row lsn is the row identity IVM reads for DUP detail tables.
   
   Reproduction before the fix (base `dim1` carries a BIGINT sequence column, 
INNER JOIN, refresh INCREMENTAL):
   
   ```
   UPDATE test_ivm_base_seq_dim1 SET name = 'a2' WHERE id = 1;
   REFRESH MATERIALIZED VIEW test_ivm_base_seq_mv_inner INCREMENTAL;
   -- expected: 1 100 a2   actual (bug): the row is gone
   ```
   
   ### Release note
   
   Fix an IVM defect where updating a base table that carries a sequence column 
could make the updated row disappear after an `INCREMENTAL` refresh.
   
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [x] Regression test
       - [x] Unit Test
   - Behavior changed:
       - [x] No.
   - Does this need documentation?
       - [x] 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