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 dump pseudo columns #11430

Merged
merged 4 commits into from
Jul 26, 2019
Merged

Conversation

alivxxx
Copy link
Contributor

@alivxxx alivxxx commented Jul 25, 2019

What problem does this PR solve?

runtime error: invalid memory address or nil pointer dereference
goroutine 25913493 [running]:
net/http.(*conn).serve.func1(0xc30491c000)
	/usr/local/go/src/net/http/server.go:1769 +0xc9
panic(0x1a4f380, 0x2c1a650)
	/usr/local/go/src/runtime/panic.go:522 +0x1b5
github.com/pingcap/tidb/util/chunk.(*Chunk).NumCols(...)
	/home/jenkins/workspace/release_tidb_2.1-ga/go/src/github.com/pingcap/tidb/util/chunk/chunk.go:272
github.com/pingcap/tidb/util/chunk.(*Chunk).NumRows(...)
	/home/jenkins/workspace/release_tidb_2.1-ga/go/src/github.com/pingcap/tidb/util/chunk/chunk.go:277
github.com/pingcap/tidb/util/chunk.(*Iterator4Chunk).Begin(...)
	/home/jenkins/workspace/release_tidb_2.1-ga/go/src/github.com/pingcap/tidb/util/chunk/iterator.go:115
github.com/pingcap/tidb/statistics.(*Histogram).ConvertTo(0xc0076fbb80, 0xc4279c9200, 0xc04faf9c20, 0xc04fca1f50, 0xc4ace6a0c0, 0x0)
	/home/jenkins/workspace/release_tidb_2.1-ga/go/src/github.com/pingcap/tidb/statistics/histogram.go:160 +0xa9
github.com/pingcap/tidb/statistics.(*Handle).tableStatsToJSON(0xc0022b0630, 0xc316905570, 0x6, 0xc004182480, 0xc2e7, 0x160, 0x3, 0x1e247b8)
	/home/jenkins/workspace/release_tidb_2.1-ga/go/src/github.com/pingcap/tidb/statistics/dump.go:103 +0x27e
github.com/pingcap/tidb/statistics.(*Handle).DumpStatsToJSON(0xc0022b0630, 0xc316905570, 0x6, 0xc004182480, 0xc856fe8088, 0xc316905577, 0xb)
	/home/jenkins/workspace/release_tidb_2.1-ga/go/src/github.com/pingcap/tidb/statistics/dump.go:64 +0x33f

What is changed and how it works?

The histograms of the pseudo table are not initialized properly, the bounds of them may be nil, so it will panic when we try to dump the stats.

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change

Side effects

  • None

Related changes

  • None

@alivxxx
Copy link
Contributor Author

alivxxx commented Jul 25, 2019

/rebuild

@codecov
Copy link

codecov bot commented Jul 25, 2019

Codecov Report

Merging #11430 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #11430   +/-   ##
===========================================
  Coverage   81.4025%   81.4025%           
===========================================
  Files           424        424           
  Lines         90846      90846           
===========================================
  Hits          73951      73951           
  Misses        11595      11595           
  Partials       5300       5300

Copy link
Contributor

@lzmhhh123 lzmhhh123 left a comment

Choose a reason for hiding this comment

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

LGTM.

@lzmhhh123 lzmhhh123 added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 25, 2019
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.

The pseudo estimation with pseudo histograms is different with that without histograms?

@alivxxx
Copy link
Contributor Author

alivxxx commented Jul 25, 2019

I think no, this PR only initialize the Bounds to an empty chunk, and there is no code that check if Bounds is nil now.

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

@eurekaka eurekaka added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jul 26, 2019
@alivxxx
Copy link
Contributor Author

alivxxx commented Jul 26, 2019

/run-all-tests

@alivxxx alivxxx added status/all tests passed status/can-merge Indicates a PR has been approved by a committer. labels Jul 26, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Jul 26, 2019

/run-all-tests

@sre-bot
Copy link
Contributor

sre-bot commented Jul 26, 2019

@lamxTyler merge failed.

@alivxxx
Copy link
Contributor Author

alivxxx commented Jul 26, 2019

/run-unit-test

@zz-jason zz-jason merged commit bd419c8 into pingcap:master Jul 26, 2019
@alivxxx alivxxx deleted the dump-panic branch July 26, 2019 06:43
@sre-bot
Copy link
Contributor

sre-bot commented Jul 26, 2019

cherry pick to release-3.0 in PR #11460

@sre-bot
Copy link
Contributor

sre-bot commented Jul 26, 2019

cherry pick to release-2.1 failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/statistics status/can-merge Indicates a PR has been approved by a committer. 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