[fix](be) Continue sorted merge when sender queue is ready#65004
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
/review |
There was a problem hiding this comment.
Review completed for PR 65004. I did not find a blocking correctness issue or any inline comment worth submitting.
Critical checkpoint conclusions:
- Goal/test proof: the PR keeps sorted exchange merging from yielding early when the exhausted sender queue already has another block or EOS ready, while preserving the pending-cursor path when it is not ready. The added BE unit tests cover eager-ready continuation, not-ready pending behavior, string-column row materialization after mid-loop flushing, and existing offset/limit/single-stream cases.
- Scope/focus: the code change is small and confined to the stream receiver ready check, sorted cursor callback, merger loop, and targeted BE unit tests.
- Concurrency/lifecycle: sender queue readiness is read under the same mutex that protects queue/cancel/EOS transitions; no new thread, lock order, or object lifetime owner is introduced.
- Configuration/compatibility: no new config/session variable, FE-BE protocol field, storage format, or rolling-upgrade compatibility surface is introduced.
- Parallel paths: non-exchange VSortedRunMerger callers keep old behavior through the default empty ready checker; sorted exchange receivers pass the new checker explicitly.
- Testing/validation: scoped git diff --check passed. I could not run the BE UT in this checkout because thirdparty/installed is absent and no prebuilt sort_merger_test binary exists.
User focus: no additional user-provided review focus was present.
Subagent conclusions: optimizer-rewrite and tests-session-config both reported no candidates in the initial pass. No candidates were accepted, dismissed as duplicates, or turned into inline comments. Convergence round 1 ended with both live subagents replying NO_NEW_VALUABLE_FINDINGS for this same summary-only final comment set.
|
run buildall |
TPC-H: Total hot run time: 29954 ms |
TPC-DS: Total hot run time: 174427 ms |
ClickBench: Total hot run time: 25.17 s |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
### What problem does this PR solve? When a sorted-run merge cursor reaches the end of its current block and the sender already has the next block ready, the merger may fetch the next block before flushing rows that have already been selected into the output block. For variable-length columns, the pending row addresses still point to the previous cursor block. Reusing the cursor block before `do_insert()` can make the output read rows from the wrong block and corrupt string offsets. ### What is changed? Flush pending output rows before loading the next ready block from the exhausted cursor. This keeps the existing non-ready path behavior unchanged: when the next block is not ready, the cursor is saved as pending and the current output block is returned first. The PR also adds regression coverage for both: - continuing merge when the next sender block is already ready - preserving string column values before the cursor block is reused
What problem does this PR solve?
When a sorted-run merge cursor reaches the end of its current block and the sender already has the next block ready, the merger may fetch the next block before flushing rows that have already been selected into the output block.
For variable-length columns, the pending row addresses still point to the previous cursor block. Reusing the cursor block before
do_insert()can make the output read rows from the wrong block and corrupt string offsets.What is changed?
Flush pending output rows before loading the next ready block from the exhausted cursor.
This keeps the existing non-ready path behavior unchanged: when the next block is not ready, the cursor is saved as pending and the current output block is returned first.
The PR also adds regression coverage for both:
Check List
./run-be-ut.sh -j 48 --run --filter=SortMergerTest.*