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

stats: fix panic when log detailed stats info #7588

Merged
merged 3 commits into from
Sep 3, 2018

Conversation

alivxxx
Copy link
Contributor

@alivxxx alivxxx commented Sep 3, 2018

What problem does this PR solve?

panic: runtime error: index out of range                                 
                                                                         
goroutine 14313 [running]:                                               
github.com/pingcap/tidb/util/chunk.(*column).isNull(...)                 
        /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/util/chunk/column.go:71
github.com/pingcap/tidb/util/chunk.Row.IsNull(...)                       
        /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/util/chunk/row.go:222
github.com/pingcap/tidb/util/chunk.Row.GetDatum(0xc000021f50, 0xffffffffffffffff, 0x0, 0xc0004a5810, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/util/chunk/row.go:174 +0xbd0
github.com/pingcap/tidb/statistics.(*Histogram).GetUpper(0xc00058cd80, 0xffffffffffffffff, 0x13503b6)
        /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/statistics/histogram.go:102 +0x82
github.com/pingcap/tidb/statistics.(*Histogram).bucketToString(0xc00058cd80, 0xffffffffffffffff, 0x0, 0x0, 0xc005c97780)
        /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/statistics/histogram.go:356 +0x4d
github.com/pingcap/tidb/statistics.formatBuckets(0xc00058cd80, 0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xb, 0x12)
        /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/statistics/feedback.go:767 +0x3e5
github.com/pingcap/tidb/statistics.colRangeToStr(0xc00058cd80, 0xc002461c20, 0xffffffffffffffff, 0x3ff448be405987b2, 0xc000345498, 0x0)
        /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/statistics/feedback.go:781 +0x14b
github.com/pingcap/tidb/statistics.logForIndex(0xc0064a1890, 0x25, 0xc0057c0060, 0xc00058db00, 0xc000734f08, 0x1, 0x1, 0xc00162ffa8, 0x1, 0x1, ...)
        /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/statistics/feedback.go:858 +0xb72

What is changed and how it works?

Only format buckets when there are buckes in the histogram, or it will panic when get the bucket boundaries. If there is no buckets, we only log the expected count.

Check List

Tests

  • Unit test

Code changes

  • Has unexported function/method change

Side effects

  • None

Related changes

  • None

PTAL @jackysp @coocood @zz-jason @winoros

Copy link
Member

@jackysp jackysp 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

@winoros winoros left a comment

Choose a reason for hiding this comment

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

lgtm

@alivxxx
Copy link
Contributor Author

alivxxx commented Sep 3, 2018

/run-all-tests

@alivxxx alivxxx added the status/LGT2 Indicates that a PR has LGTM 2. label Sep 3, 2018
@shenli
Copy link
Member

shenli commented Sep 3, 2018

Do we need to cherry-pick it to the release-2.0?

@alivxxx
Copy link
Contributor Author

alivxxx commented Sep 3, 2018

@shenli No, because release 2.0 does not log the stats info for feedback.

@alivxxx alivxxx merged commit aa9f46a into pingcap:master Sep 3, 2018
@alivxxx alivxxx deleted the log-panic branch September 3, 2018 08:53
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.

4 participants