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

analyze partition panic #39121

Closed
aytrack opened this issue Nov 14, 2022 · 1 comment · Fixed by #39123
Closed

analyze partition panic #39121

aytrack opened this issue Nov 14, 2022 · 1 comment · Fixed by #39123
Assignees
Labels

Comments

@aytrack
Copy link
Contributor

aytrack commented Nov 14, 2022

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE `t` (   `id` int(11) DEFAULT NULL,   `a` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL, `c` int(11) DEFAULT NULL ) PARTITION BY RANGE (`id`) (PARTITION `p0` VALUES LESS THAN (3),  PARTITION `p1` VALUES LESS THAN (7),  PARTITION `p2` VALUES LESS THAN (11));
insert into t values (1,1,1,1),(2,2,2,2),(4,4,4,4),(5,5,5,5),(6,6,6,6),(8,8,8,8),(9,9,9,9);
create index idxa on t (a);
create index idxb on t (b);
create index idxc on t (c);
analyze table t partition p0 index idxa;
analyze table t partition p1 index idxb;
analyze table t partition p2 index idxc;
set tidb_partition_prune_mode=dynamic;
analyze table t partition p0;

2. What did you expect to see? (Required)

analyze success.

3. What did you see instead (Required)

report panic
(1105, 'runtime error: invalid memory address or nil pointer dereference')

[2022/11/14 11:46:57.259 +08:00] [ERROR] [conn.go:1058] ["connection running loop panic"] [conn=2199023255957] [lastSQL="analyze table t partition p0 index idxa"] [err="runtime error: invalid memory address or nil pointer dereference"] [stack="github.com/pingcap/tidb/server.(*clientConn).Run.func1\n\t/Users/pingcap/workspace/build-common/go/src/github.com/pingcap/tidb/server/conn.go:1061\nruntime.gopanic\n\t/usr/local/go1.19.2/src/runtime/panic.go:884\ngithub.com/pingcap/tidb/executor.(*ExecStmt).Exec.func1\n\t/Users/pingcap/workspace/build-common/go/src/github.com/pingcap/tidb/executor/adapter.go:438\nruntime.gopanic\n\t/usr/local/go1.19.2/src/runtime/panic.go:884\nruntime.panicmem\n\t/usr/local/go1.19.2/src/runtime/panic.go:260\nruntime.sigpanic\n\t/usr/local/go1.19.2/src/runtime/signal_unix.go:835\ngithub.com/pingcap/tidb/statistics.MergePartitionHist2GlobalHist\n\t/Users/pingcap/workspace/build-common/go/src/github.com/pingcap/tidb/statistics/histogram.go:1371\ngithub.com/pingcap/tidb/statistics/handle.(*Handle).mergePartitionStats2GlobalStats\n\t/Users/pingcap/workspace/build-common/go/src/github.com/pingcap/tidb/statistics/handle/handle.go:562\ngithub.com/pingcap/tidb/statistics/handle.(*Handle).MergePartitionStats2GlobalStatsByTableID\n\t/Users/pingcap/workspace/build-common/go/src/github.com/pingcap/tidb/statistics/handle/handle.go:424\ngithub.com/pingcap/tidb/executor.(*AnalyzeExec).handleGlobalStats.func1\n\t/Users/pingcap/workspace/build-common/go/src/github.com/pingcap/tidb/executor/analyze_global_stats.go:72\ngithub.com/pingcap/tidb/executor.(*AnalyzeExec).handleGlobalStats\n\t/Users/pingcap/workspace/build-common/go/src/github.com/pingcap/tidb/executor/analyze_global_stats.go:96\ngithub.com/pingcap/tidb/executor.(*AnalyzeExec).Next\n\t/Users/pingcap/workspace/build-common/go/src/github.com/pingcap/tidb/executor/analyze.go:130\ngithub.com/pingcap/tidb/executor.Next\n\t/Users/pingcap/workspace/build-common/go/src/github.com/pingcap/tidb/executor/executor.go:325\ngithub.com/pingcap/tidb/executor.(*ExecStmt).next\n\t/Users/pingcap/workspace/build-common/go/src/github.com/pingcap/tidb/executor/adapter.go:1118\ngithub.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelayExecutor\n\t/Users/pingcap/workspace/build-common/go/src/github.com/pingcap/tidb/executor/adapter.go:891\ngithub.com/pingcap/tidb/executor.(*ExecStmt).handleNoDelay\n\t/Users/pingcap/workspace/build-common/go/src/github.com/pingcap/tidb/executor/adapter.go:739\ngithub.com/pingcap/tidb/executor.(*ExecStmt).Exec\n\t/Users/pingcap/workspace/build-common/go/src/github.com/pingcap/tidb/executor/adapter.go:544\ngithub.com/pingcap/tidb/session.runStmt\n\t/Users/pingcap/workspace/build-common/go/src/github.com/pingcap/tidb/session/session.go:2322\ngithub.com/pingcap/tidb/session.(*session).ExecuteStmt\n\t/Users/pingcap/workspace/build-common/go/src/github.com/pingcap/tidb/session/session.go:2186\ngithub.com/pingcap/tidb/server.(*TiDBContext).ExecuteStmt\n\t/Users/pingcap/workspace/build-common/go/src/github.com/pingcap/tidb/server/driver_tidb.go:233\ngithub.com/pingcap/tidb/server.(*clientConn).handleStmt\n\t/Users/pingcap/workspace/build-common/go/src/github.com/pingcap/tidb/server/conn.go:2065\ngithub.com/pingcap/tidb/server.(*clientConn).handleQuery\n\t/Users/pingcap/workspace/build-common/go/src/github.com/pingcap/tidb/server/conn.go:1920\ngithub.com/pingcap/tidb/server.(*clientConn).dispatch\n\t/Users/pingcap/workspace/build-common/go/src/github.com/pingcap/tidb/server/conn.go:1374\ngithub.com/pingcap/tidb/server.(*clientConn).Run\n\t/Users/pingcap/workspace/build-common/go/src/github.com/pingcap/tidb/server/conn.go:1123\ngithub.com/pingcap/tidb/server.(*Server).onConn\n\t/Users/pingcap/workspace/build-common/go/src/github.com/pingcap/tidb/server/server.go:625"]

4. What is your TiDB version? (Required)

TiDB root@127.0.0.1:test> select tidb_version()\G
Reconnecting...
***************************[ 1. row ]***************************
tidb_version() | Release Version: v6.4.0
Edition: Community
Git Commit Hash: cf36a9ce2fe1039db3cf3444d51930b887df18a1
Git Branch: heads/refs/tags/v6.4.0
UTC Build Time: 2022-11-13 05:15:26
GoVersion: go1.19.2
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: unistore
@aytrack aytrack added type/bug The issue is confirmed as a bug. sig/planner SIG: Planner severity/major labels Nov 14, 2022
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 labels Nov 14, 2022
@Yisaer Yisaer added affects-6.3 and removed may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 labels Nov 14, 2022
@Yisaer
Copy link
Contributor

Yisaer commented Nov 14, 2022

The main reason is that the partition table stats haven't been analyzed when merging stats, as we enabled dynamic on v6.3.0, thus the affects-version-range is adjusted to v6.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants