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

*: fix bug when unsigned pk meets feedback ranges #10307

Merged
merged 9 commits into from
Jun 4, 2019

Conversation

winoros
Copy link
Member

@winoros winoros commented Apr 29, 2019

What problem does this PR solve?

fix #10242

What is changed and how it works?

Port some codes from #7921

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change

Related changes

  • Need to be included in the release note

@winoros winoros added the type/bugfix This PR fixes a bug. label Apr 29, 2019
statistics/histogram.go Outdated Show resolved Hide resolved
@shenli
Copy link
Member

shenli commented Apr 30, 2019

Could you add some test cases?

@winoros
Copy link
Member Author

winoros commented Apr 30, 2019

@eurekaka
We need to move it because of the following reasons.

  1. In TableRangesToKVRanges, we encode the ranger.Range to kv.KeyRange. Since we store unsigned pk as int pk in physical kv layer in fact, unsigned ones are stored before signed ones in fact.
  2. But the SplitRange will put the unsigned ones after signed ones since it stores logical value.
  3. And if the reader doesn't set KeepOrder true. We do give TableRangesToKVRanges a full range contain both unsigned part and signed part. Then we got a wrong Range slice after Histogram.SplitRange.

So if we need to call Histogram.SplitRange, we should call it earlier to avoid this bug.

@winoros
Copy link
Member Author

winoros commented Apr 30, 2019

When adding tests, finding that though the response can be sent correctly, but the feedback cannot be updated correctly. Need more changes to correct it.
Master has the same problem, it can be replayed easily if we change the column type from tinyint to bigint in unit test TestUnsignedFeedbackRanges.
/cc @lamxTyler

@@ -96,6 +96,9 @@ func (e *TableReaderExecutor) Open(ctx context.Context) error {
}

e.resultHandler = &tableResultHandler{}
if e.feedback != nil && e.feedback.Hist() != nil {
e.ranges = e.feedback.Hist().SplitRange(e.ranges)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, please add the comment here to inform that SplitRange must be placed before splitRanges and explain the reasons.

@winoros winoros requested a review from eurekaka May 23, 2019 12:46
@winoros
Copy link
Member Author

winoros commented May 23, 2019

@lamxTyler @eurekaka Addressed, PTAL

@eurekaka
Copy link
Contributor

@winoros CI failed, PTAL

@winoros
Copy link
Member Author

winoros commented May 24, 2019

@eurekaka fixed

@winoros
Copy link
Member Author

winoros commented May 27, 2019

@lamxTyler Fixed

statistics/feedback.go Outdated Show resolved Hide resolved
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

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

@zz-jason zz-jason added the status/LGT2 Indicates that a PR has LGTM 2. label May 28, 2019
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

@zz-jason zz-jason merged commit 02526b6 into pingcap:release-2.1 Jun 4, 2019
@winoros winoros deleted the feedback-unsigned-ranges branch June 13, 2019 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/statistics 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.

6 participants