-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix](planner) query should be cancelled if limit reached #44338
Conversation
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
a1a7aee
to
ee3851c
Compare
run buildall |
PR approved by at least one committer and no changes requested. |
PR approved by anyone and no changes requested. |
run buildall |
241dae2
to
b6e3041
Compare
run buildall |
1 similar comment
run buildall |
PR approved by at least one committer and no changes requested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
d886471
to
d12d3f9
Compare
run buildall |
TeamCity be ut coverage result: |
11438bc
to
a7bca98
Compare
run buildall |
@@ -316,6 +318,17 @@ void ScannerScheduler::_scanner_scan(std::shared_ptr<ScannerContext> ctx, | |||
ctx->inc_block_usage(free_block->allocated_bytes()); | |||
scan_task->cached_blocks.emplace_back(std::move(free_block), free_block_bytes); | |||
} | |||
if (limit < ctx->batch_size()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if limit == -1? not limit query will be true
. better the check in while loop ?
2 3 1 4 bytes limit
a7bca98
to
670d90e
Compare
run buildall |
TeamCity be ut coverage result: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR approved by at least one committer and no changes requested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Problem Summary: When there is a `limit` cluse in SQL, if FE has obtained data with more than the `limit` number of rows, it should send a cancel command to BE to cancel the query to prevent BE from reading more data. However, this function has problems in the current code and does not work. Especially in external table query, this may result in lots of unnecessary network io read. 1. `isBlockQuery` In the old optimizer, if a query statement contains a `sort` or `agg` node, `isBlockQuery` will be marked as true, otherwise it will be false. In the new optimizer, this value is always true. Regardless of the old or new optimizer, this logic is wrong. But only when `isBlockQuery = false` will the reach limit logic be triggered. 2. Calling problem of reach limit logic The reach limit logic judgment will only be performed when `eos = true` in the rowBatch returned by BE. This is wrong. Because for `limit N` queries, each BE's own `limit` is N. But for FE, as long as the total number of rows returned by all BEs exceeds N, the reach limit logic can be triggered. So it should not be processed only when `eos = true`. The PR mainly changes: 1. Remove `isBlockQuery` `isBlockQuery` is only used in the reach limit logic. And it is not needed. Remove it completely. 2. Modify the judgment position of reach limit. When the number of rows obtained by FE is greater than the limit, it will check the reach limit logic. 3. fix wrong `limitRows` in `QueryProcessor` the limitRows should be got from the first fragment, not last. 4. In scanner scheduler on BE side, if scanner has limit, ignore the scan bytes threshold per round. [fix](planner) query should be cancelled if limit reached
Problem Summary: When there is a `limit` cluse in SQL, if FE has obtained data with more than the `limit` number of rows, it should send a cancel command to BE to cancel the query to prevent BE from reading more data. However, this function has problems in the current code and does not work. Especially in external table query, this may result in lots of unnecessary network io read. 1. `isBlockQuery` In the old optimizer, if a query statement contains a `sort` or `agg` node, `isBlockQuery` will be marked as true, otherwise it will be false. In the new optimizer, this value is always true. Regardless of the old or new optimizer, this logic is wrong. But only when `isBlockQuery = false` will the reach limit logic be triggered. 2. Calling problem of reach limit logic The reach limit logic judgment will only be performed when `eos = true` in the rowBatch returned by BE. This is wrong. Because for `limit N` queries, each BE's own `limit` is N. But for FE, as long as the total number of rows returned by all BEs exceeds N, the reach limit logic can be triggered. So it should not be processed only when `eos = true`. The PR mainly changes: 1. Remove `isBlockQuery` `isBlockQuery` is only used in the reach limit logic. And it is not needed. Remove it completely. 2. Modify the judgment position of reach limit. When the number of rows obtained by FE is greater than the limit, it will check the reach limit logic. 3. fix wrong `limitRows` in `QueryProcessor` the limitRows should be got from the first fragment, not last. 4. In scanner scheduler on BE side, if scanner has limit, ignore the scan bytes threshold per round. [fix](planner) query should be cancelled if limit reached
What problem does this PR solve?
Problem Summary:
When there is a
limit
cluse in SQL, if FE has obtained data with more than thelimit
number of rows,it should send a cancel command to BE to cancel the query to prevent BE from reading more data.
However, this function has problems in the current code and does not work.
Especially in external table query, this may result in lots of unnecessary network io read.
isBlockQuery
In the old optimizer, if a query statement contains a
sort
oragg
node,isBlockQuery
will be marked as true, otherwise it will be false.In the new optimizer, this value is always true.
Regardless of the old or new optimizer, this logic is wrong.
But only when
isBlockQuery = false
will the reach limit logic be triggered.Calling problem of reach limit logic
The reach limit logic judgment will only be performed when
eos = true
in the rowBatch returned by BE.This is wrong.
Because for
limit N
queries, each BE's ownlimit
is N. But for FE, as long as the total number of rowsreturned by all BEs exceeds N, the reach limit logic can be triggered.
So it should not be processed only when
eos = true
.The PR mainly changes:
Remove
isBlockQuery
isBlockQuery
is only used in the reach limit logic. And it is not needed. Remove it completely.Modify the judgment position of reach limit.
When the number of rows obtained by FE is greater than the limit,
it will check the reach limit logic.
fix wrong
limitRows
inQueryProcessor
the limitRows should be got from the first fragment, not last.
In scanner scheduler on BE side, if scanner has limit, ignore the scan bytes threshold per round.
Release note
fix query should be cancelled if limit reached
Check List (For Author)
Test
test single and multi-be nodes with limit sql.
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)