-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix](result-sink)Fix the correctness of the results when multiple be and dry_run_query=true. #53653
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
Conversation
… and dry_run_query=true.
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
TPC-H: Total hot run time: 34231 ms |
TPC-DS: Total hot run time: 190819 ms |
ClickBench: Total hot run time: 32.62 s |
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
|
Can you add some test case for this problem? |
There is already p2 case. |
| // statistics->set_returned_rows(returned_rows); | ||
| // In a multi-mysql_result_writer scenario, since each mysql_result_writer will set this rows, in order | ||
| // to avoid missing rows when dry_run_query = true, they should all be added up. | ||
| numReceivedRows += resultBatch.getQueryStatistics().getReturnedRows(); |
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 one backend returns multiple batches, does it will the repeated calculation lead to result row number more than real?
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.
I don't think it will happen. returned_rows set by BE will only be increased during the close phase of ResultBlockBuffer. Reference:
src/runtime/result_block_buffer.cpp:ResultBlockBuffer<ResultCtxType>::close(....)
… and dry_run_query=true. (apache#53653) Related PR: apache#36053 && apache#53209 Problem Summary: Fixed the issue that the result of `dry_run_query=true` is wrong in multi-be scenarios (the number of rows is less) I think this may be related to the multi result sink introduced in pr apache#36053 && apache#53209. Reason: ```cpp vmysql_result_writer.cpp GetResultBatchCtx::on_close() { ... statistics->set_returned_rows(returned_rows); // Set only once per result_writer. ... } ``` ``` java if (connectContext != null && connectContext.getSessionVariable().dryRunQuery) { if (resultBatch.isEos()) { // This will only be counted once. numReceivedRows += resultBatch.getQueryStatistics().getReturnedRows(); } } else if (resultBatch.getBatch() != null) { numReceivedRows += resultBatch.getBatch().getRowsSize(); } ``` If there are multiple be, there will be multiple result sinks, and each result sink will update its own row count at the end. Since `resultBatch.isEos()` is only triggered once, the row count information is less.
What problem does this PR solve?
Related PR: #36053 && #53209
Problem Summary:
Fixed the issue that the result of
dry_run_query=trueis wrong in multi-be scenarios (the number of rows is less)I think this may be related to the multi result sink introduced in pr #36053 && #53209.
Reason:
If there are multiple be, there will be multiple result sinks, and each result sink will update its own row count at the end. Since
resultBatch.isEos()is only triggered once, the row count information is less.Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)