Repository navigation
Commit c54b0b6
[fix](be) Do not push storage TopN to a MOR table read as DUP
### 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
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>1 parent 038e227 commit c54b0b6
3 files changed
Lines changed: 96 additions & 3 deletions
File tree
- be/src/exec/scan
- regression-test
- data/unique_with_mor_p0
- suites/unique_with_mor_p0
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
478 | 481 | | |
479 | 482 | | |
480 | 483 | | |
| |||
486 | 489 | | |
487 | 490 | | |
488 | 491 | | |
489 | | - | |
490 | | - | |
491 | | - | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
492 | 496 | | |
493 | 497 | | |
494 | 498 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
0 commit comments