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

   ### What problem does this PR solve?
   
   Issue Number: None
   
   Related PR: #62222
   
   Problem Summary:
   
   A merge-on-read UNIQUE table listed in read_mor_as_dup_tables is read 
without merging, so OlapScanLocalState::_storage_no_merge() is true for it. 
Since #62222 the scanner alone decides whether VCollectIterator takes the 
storage TopN path, and it pushes read_orderby_key_limit for every key TopN scan 
where _storage_no_merge() holds. TabletReader::_init_orderby_keys_param() 
prepares the key columns that VCollectIterator::_topn_next() compares only for 
DUP_KEYS and merge-on-write UNIQUE_KEYS tablets, so for a MOR table read as DUP 
read_orderby_key_columns stays null and the DORIS_CHECK at the top of 
_topn_next() aborts the BE. FE pushes the sort info to the scan for any table 
whose ORDER BY is a key prefix, so a plain query is enough:
   
       -- mor_tbl: UNIQUE KEY(k1, k2), enable_unique_key_merge_on_write = false
       SET read_mor_as_dup_tables = 'mor_tbl';
       SELECT * FROM mor_tbl ORDER BY k1, k2 LIMIT 4;
       -- ERROR 1105 (HY000): RpcException, msg: send fragments failed.
       -- be.out: Check failed: 
_reader->_reader_context.read_orderby_key_columns != nullptr
   
   The scanner now keeps segment LIMIT off for a key TopN on a MOR table read 
as DUP. The scan returns every row and the TopN operator above sorts them, the 
same as any key TopN that is not pushed to storage. A plain LIMIT on such a 
table is still pushed to SegmentIterator.
   
   ### Release note
   
   Fix a BE crash on ORDER BY <key> LIMIT queries over a merge-on-read unique 
table listed in read_mor_as_dup_tables.
   
   ### Check List (For Author)
   
   - Test: Regression test
       - unique_with_mor_p0/test_read_mor_as_dup_key_topn: aborts the BE before 
this change, passes after.
       - unique_with_mor_p0/test_read_mor_as_dup and all 19 suites in 
query_p0/limit pass.
   - Behavior changed: No
   - Does this need documentation: No
   
   ### What problem does this PR solve?
   
   Issue Number: close #xxx
   
   Related PR: #xxx
   
   Problem Summary:
   
   ### Release note
   
   None
   
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [ ] Regression test
       - [ ] 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 <!-- Add your reason?  -->
   
   - Behavior changed:
       - [ ] No.
       - [ ] Yes. <!-- Explain the behavior change -->
   
   - Does this need documentation?
       - [ ] No.
       - [ ] Yes. <!-- Add document PR link here. eg: 
https://github.com/apache/doris-website/pull/1214 -->
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should 
merge into -->
   
   


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