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

panic raised by show stats_histograms #9479

Closed
eurekaka opened this issue Feb 27, 2019 · 0 comments
Closed

panic raised by show stats_histograms #9479

eurekaka opened this issue Feb 27, 2019 · 0 comments
Assignees
Labels
component/statistics sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@eurekaka
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?

Add these test lines into TestShowStatsHistograms:

diff --git a/executor/show_stats_test.go b/executor/show_stats_test.go
index 05987b5..81e1771 100644
--- a/executor/show_stats_test.go
+++ b/executor/show_stats_test.go
@@ -47,6 +47,15 @@ func (s *testSuite1) TestShowStatsHistograms(c *C) {
        result = tk.MustQuery("show stats_histograms where column_name = 'a'")
        c.Assert(len(result.Rows()), Equals, 1)
        c.Assert(result.Rows()[0][3], Equals, "a")
+
+       tk.MustExec("drop table t")
+       tk.MustExec("create table t(a int, b int, c int, index idx_b(b), index idx_c_a(c, a))")
+       tk.MustExec("insert into t values(1,null,1),(2,null,2),(3,3,3),(4,null,4),(null,null,null)")
+       res := tk.MustQuery("show stats_histograms where table_name = 't'")
+       c.Assert(len(res.Rows()), Equals, 0)
+       tk.MustExec("analyze table t index idx_b")
+       res = tk.MustQuery("show stats_histograms where table_name = 't' and column_name = 'idx_b'")
+       c.Assert(len(res.Rows()), Equals, 1)
 }

then run go test under executor package.

  1. What did you expect to see?

Test result should be either OK or FAIL, not PANIC.

  1. What did you see instead?
----------------------------------------------------------------------
PANIC: show_stats_test.go:37: testSuite1.TestShowStatsHistograms

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

/usr/local/go/src/runtime/panic.go:513
  in gopanic
/usr/local/go/src/runtime/panic.go:82
  in panicmem
/usr/local/go/src/runtime/signal_unix.go:390
  in sigpanic
/root/go/src/github.com/pingcap/tidb/statistics/histogram.go:112
  in Column.AvgColSize
show_stats.go:85
  in ShowExec.appendTableForStatsHistograms
show_stats.go:69
  in ShowExec.fetchShowStatsHistogram
show.go:147
  in ShowExec.fetchAll
show.go:74
  in ShowExec.Next
executor.go:928
  in SelectionExec.Next
adapter.go:104
  in recordSet.Next
/root/go/src/github.com/pingcap/tidb/session/tidb.go:264
  in GetRows4Test
/root/go/src/github.com/pingcap/tidb/util/testkit/testkit.go:211
  in TestKit.ResultSetToResult
/root/go/src/github.com/pingcap/tidb/util/testkit/testkit.go:185
  in TestKit.MustQuery
show_stats_test.go:57
  in testSuite1.TestShowStatsHistograms
/usr/local/go/src/reflect/value.go:308
  in Value.Call
/root/go/pkg/mod/github.com/pingcap/[email protected]/check.go:836
  in suiteRunner.forkTest.func1
/root/go/pkg/mod/github.com/pingcap/[email protected]/check.go:730
  in suiteRunner.forkCall.func1
/usr/local/go/src/runtime/asm_amd64.s:1333
  in goexit
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
Release Version: v3.0.0-beta-124-g511a80b-dirty
Git Commit Hash: 511a80bae4d37b65b7f9e41e23f700c9b4c79584
Git Branch: master
UTC Build Time: 2019-02-23 11:33:57
GoVersion: go version go1.11.2 linux/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/statistics sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

1 participant