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

Merged
merged 6 commits into from
Nov 26, 2018
Merged

Conversation

alivxxx
Copy link
Contributor

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

Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

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

LGTM

@XuHuaiyu XuHuaiyu added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 26, 2018
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 Nov 26, 2018

/run-all-tests

@alivxxx alivxxx added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Nov 26, 2018
@zz-jason zz-jason merged commit 8be09da into pingcap:master Nov 26, 2018
@alivxxx alivxxx deleted the dump-stats branch November 27, 2018 02:49
alivxxx added a commit to alivxxx/tidb that referenced this pull request Nov 27, 2018
alivxxx added a commit to alivxxx/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
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.

5 participants