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 dumping stats #8448

Merged
merged 6 commits into from Nov 26, 2018

Conversation

Projects
None yet
5 participants
@lamxTyler
Member

lamxTyler commented Nov 26, 2018

What problem does this PR solve?

When dumping stats, we get panic log like:

... Panic: runtime error: invalid memory address or nil pointer dereference (PC=0x45B81A)

/usr/lib/go/src/runtime/panic.go:513
  in gopanic
/usr/lib/go/src/runtime/panic.go:82
  in panicmem
/usr/lib/go/src/runtime/signal_unix.go:390
  in sigpanic
/home/aliv/go/src/github.com/pingcap/tidb/util/chunk/chunk.go:241
  in Histogram.ConvertTo
histogram.go:159
  in Histogram.ConvertTo
dump.go:103
  in Handle.tableStatsToJSON
dump.go:64
  in Handle.DumpStatsToJSON

What is changed and how it works?

If the column is not primary key, we will load the bucket info by need, thus leaving the Bound as nil. If the column is droped, we will not delete it immediately, so this column will still be in the cache, so when dumping the stats, we will meet panic when using the Bound info.

This PR fixes this by assigning empty chunk to Bound, so it will never be nil, and this will make future code does not meet the same problem again.

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change

Side effects

  • None

Related changes

  • Need to cherry-pick to the release branch

This change is Reviewable

@winoros

lgtm

@lamxTyler

This comment has been minimized.

Member

lamxTyler commented Nov 26, 2018

/run-all-tests

@lamxTyler lamxTyler added status/LGT2 and removed status/LGT1 labels Nov 26, 2018

zz-jason added some commits Nov 26, 2018

@zz-jason zz-jason merged commit 8be09da into pingcap:master Nov 26, 2018

4 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jenkins-ci-tidb/build Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details

@lamxTyler lamxTyler deleted the lamxTyler:dump-stats branch Nov 27, 2018

lamxTyler added a commit to lamxTyler/tidb that referenced this pull request Nov 27, 2018

lamxTyler added a commit to lamxTyler/tidb that referenced this pull request Nov 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment