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

planner, executor: inject proj below TopN and Sort if byItem contains scalarFunc #9197

Merged
merged 9 commits into from
Feb 15, 2019

Conversation

XuHuaiyu
Copy link
Contributor

What problem does this PR solve?

Fix #9047

What is changed and how it works?

The issue is caused by the re-usage of chunk between SortExec/TopNExec and HashAggExec. Different chunks have different capacity thus the growth of SortExec.rowChunks and SortExec.keyChunks is not exactly the same( SortExec.rowChunks.NumChunks() != SortExec.keyChunks.NumChunks()), so index outof range error may be raised when we use a singe rowPtr to record the position of every rows in SortExec.rowChunks and SortExec.keyChunks.

Inject a Projection below TopN/ Sort when Orderby-item contains scalar function(s). Thus we can remove the keyChunks from SortExec and fix the issue.

Check List

Tests

  • Integration test
  • Manual test
  • Exists tests

Code changes

  • Has exported function/method change
  • Has exported variable/fields change

Side effects
N/A

Related changes

  • Need to cherry-pick to the release branch

@XuHuaiyu XuHuaiyu added type/bugfix This PR fixes a bug. sig/planner SIG: Planner sig/execution SIG execution labels Jan 28, 2019
@codecov-io
Copy link

codecov-io commented Jan 28, 2019

Codecov Report

Merging #9197 into master will decrease coverage by <.01%.
The diff coverage is 94.02%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9197      +/-   ##
==========================================
- Coverage   67.19%   67.18%   -0.01%     
==========================================
  Files         371      371              
  Lines       77531    77511      -20     
==========================================
- Hits        52096    52077      -19     
+ Misses      20784    20780       -4     
- Partials     4651     4654       +3
Impacted Files Coverage Δ
executor/sort.go 76.8% <100%> (+2.64%) ⬆️
planner/core/rule_inject_extra_projection.go 94.82% <92.85%> (-2%) ⬇️
util/systimemon/systime_mon.go 80% <0%> (-20%) ⬇️
ddl/session_pool.go 82.75% <0%> (-10.35%) ⬇️
ddl/delete_range.go 73.54% <0%> (-4.24%) ⬇️
executor/join.go 77.86% <0%> (-1.05%) ⬇️
executor/executor.go 66.89% <0%> (-0.14%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d4ad1f...2d8e5c3. Read the comment docs.

Copy link
Contributor

@alivxxx alivxxx left a comment

Choose a reason for hiding this comment

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

LGTM

planner/core/rule_inject_extra_projection.go Show resolved Hide resolved
planner/core/rule_inject_extra_projection.go Outdated Show resolved Hide resolved
planner/core/rule_inject_extra_projection.go Show resolved Hide resolved
executor/sort.go Show resolved Hide resolved
Copy link
Contributor

@eurekaka eurekaka left a comment

Choose a reason for hiding this comment

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

LGTM. Defer the approve to @zz-jason since he has open comments left.

@eurekaka eurekaka added the status/LGT2 Indicates that a PR has LGTM 2. label Feb 15, 2019
Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution sig/planner SIG: Planner status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lost connection to MySQL server during query-index out of range
7 participants