Skip to content
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

Avoid out of bound InsertRangeFrom exception in MergingSortedBlockInputStream #8445

Merged
merged 5 commits into from
Dec 4, 2023

Conversation

yibin87
Copy link
Contributor

@yibin87 yibin87 commented Nov 30, 2023

What problem does this PR solve?

Issue Number: close #8438

Problem Summary:

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

Signed-off-by: yibin <huyibin@pingcap.com>
@ti-chi-bot ti-chi-bot bot added release-note-none size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 30, 2023
@yibin87
Copy link
Contributor Author

yibin87 commented Nov 30, 2023

/run-all-tests

Signed-off-by: yibin <huyibin@pingcap.com>
Signed-off-by: yibin <huyibin@pingcap.com>
Signed-off-by: yibin <huyibin@pingcap.com>
@ti-chi-bot ti-chi-bot bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 1, 2023
Copy link
Contributor

@xzhangxian1008 xzhangxian1008 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -175,7 +175,7 @@ void MergingSortedBlockInputStream::merge(MutableColumns & merged_columns, std::
*/
auto count_row_and_check_limit = [&, this]() {
++total_merged_rows;
if (limit && total_merged_rows == limit)
if (limit && total_merged_rows >= limit)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this cause the number of rows output by MergingSortedBlockInputStream to be greater than limit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, the element is inserted before this function, although it won't affect query correctness, it do introduce tricky behavior. I've updated the code to finish execution immediately when limit is reached.

Signed-off-by: yibin <huyibin@pingcap.com>
@ti-chi-bot ti-chi-bot bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 4, 2023
@yibin87 yibin87 requested a review from SeaRise December 4, 2023 01:54
Copy link
Contributor

@SeaRise SeaRise left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ti-chi-bot ti-chi-bot bot added the lgtm label Dec 4, 2023
Copy link
Contributor

ti-chi-bot bot commented Dec 4, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: SeaRise, xzhangxian1008

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Contributor

ti-chi-bot bot commented Dec 4, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-12-01 09:28:08.39121923 +0000 UTC m=+1174117.056445420: ☑️ agreed by xzhangxian1008.
  • 2023-12-04 05:29:38.007373301 +0000 UTC m=+1419006.672599490: ☑️ agreed by SeaRise.

@yibin87
Copy link
Contributor Author

yibin87 commented Dec 4, 2023

/run-all-tests

@ti-chi-bot ti-chi-bot bot merged commit 64fdd5f into pingcap:master Dec 4, 2023
6 checks passed
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-5.4: #8452.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.1: #8453.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #8454.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #8455.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #8456.

ti-chi-bot bot pushed a commit that referenced this pull request Dec 6, 2023
ti-chi-bot bot pushed a commit that referenced this pull request Dec 7, 2023
ti-chi-bot bot pushed a commit that referenced this pull request Dec 7, 2023
ti-chi-bot bot pushed a commit that referenced this pull request Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-5.4 Type: Need cherry pick to release-5.4 needs-cherry-pick-release-6.1 Type: Need cherry pick to release-6.1 needs-cherry-pick-release-6.5 needs-cherry-pick-release-7.1 needs-cherry-pick-release-7.5 release-note-none size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

InsertRangeFrom out of bound in MergingSortedBlockInputStream
5 participants