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 in execAnalyzeStmt invalid memory address or nil pointer dereference #58020

Closed
lilinghai opened this issue Dec 5, 2024 · 2 comments · Fixed by #58021
Closed

panic in execAnalyzeStmt invalid memory address or nil pointer dereference #58020

lilinghai opened this issue Dec 5, 2024 · 2 comments · Fixed by #58021
Assignees
Labels
affects-8.5 This bug affects the 8.5.x(LTS) versions. impact/panic severity/critical sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@lilinghai
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

million tables scenario
auto analyze panic

[2024/12/05 13:16:36.830 +00:00] [INFO] [refresher.go:156] ["Auto analyze triggered"] [category=stats] [job="NonPartitionedTableAnalysisJob:\n\tAnalyzeType: analyzeIndex\n\tIndexes: k_2, ek1, ek2, ek3, ek4, ek5, ek6\n\tSchema: sbtest580553\n\tTable: sbtest2\n\tTableID: 4561888\n\tTableStatsVer: 210000\n\tChangePercentage: 1.000000\n\tTableSize: 140000.00\n\tLastAnalysisDuration: 173h5m36.86s\n\tWeight: 3.657332\n"]
[2024/12/05 13:16:36.830 +00:00] [INFO] [worker.go:91] ["Job submitted"] [category=stats] [job="NonPartitionedTableAnalysisJob:\n\tAnalyzeType: analyzeIndex\n\tIndexes: k_2, ek1, ek2, ek3, ek4, ek5, ek6\n\tSchema: sbtest580553\n\tTable: sbtest2\n\tTableID: 4561888\n\tTableStatsVer: 210000\n\tChangePercentage: 1.000000\n\tTableSize: 140000.00\n\tLastAnalysisDuration: 173h5m36.86s\n\tWeight: 3.657332\n"]
[2024/12/05 13:16:36.830 +00:00] [WARN] [exec.go:98] ["panic in execAnalyzeStmt"] [error="runtime error: invalid memory address or nil pointer dereference"] [stack="github.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/exec.RunAnalyzeStmt.func1\n\t/workspace/source/tidb/pkg/statistics/handle/autoanalyze/exec/exec.go:98\nruntime.gopanic\n\t/usr/local/go/src/runtime/panic.go:785\nruntime.panicmem\n\t/usr/local/go/src/runtime/panic.go:262\nruntime.sigpanic\n\t/usr/local/go/src/runtime/signal_unix.go:917\ngithub.com/pingcap/tidb/pkg/util/sqlexec.GetExecOption\n\t/workspace/source/tidb/pkg/util/sqlexec/restricted_sql_executor.go:134\ngithub.com/pingcap/tidb/pkg/session.(*session).withRestrictedSQLExecutor\n\t/workspace/source/tidb/pkg/session/session.go:1933\ngithub.com/pingcap/tidb/pkg/session.(*session).ExecRestrictedSQL\n\t/workspace/source/tidb/pkg/session/session.go:1958\ngithub.com/pingcap/tidb/pkg/statistics/handle/util.ExecWithOpts\n\t/workspace/source/tidb/pkg/statistics/handle/util/util.go:263\ngithub.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/exec.RunAnalyzeStmt\n\t/workspace/source/tidb/pkg/statistics/handle/autoanalyze/exec/exec.go:102\ngithub.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/exec.AutoAnalyze\n\t/workspace/source/tidb/pkg/statistics/handle/autoanalyze/exec/exec.go:55\ngithub.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/priorityqueue.(*NonPartitionedTableAnalysisJob).analyzeIndexes\n\t/workspace/source/tidb/pkg/statistics/handle/autoanalyze/priorityqueue/non_partitioned_table_analysis_job.go:263\ngithub.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/priorityqueue.(*NonPartitionedTableAnalysisJob).Analyze.func2\n\t/workspace/source/tidb/pkg/statistics/handle/autoanalyze/priorityqueue/non_partitioned_table_analysis_job.go:105\ngithub.com/pingcap/tidb/pkg/statistics/handle/util.CallWithSCtx\n\t/workspace/source/tidb/pkg/statistics/handle/util/util.go:106\ngithub.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/priorityqueue.(*NonPartitionedTableAnalysisJob).Analyze\n\t/workspace/source/tidb/pkg/statistics/handle/autoanalyze/priorityqueue/non_partitioned_table_analysis_job.go:100\ngithub.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/refresher.(*worker).processJob\n\t/workspace/source/tidb/pkg/statistics/handle/autoanalyze/refresher/worker.go:102\ngithub.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/refresher.(*worker).SubmitJob.func1\n\t/workspace/source/tidb/pkg/statistics/handle/autoanalyze/refresher/worker.go:83\ngithub.com/pingcap/tidb/pkg/util.(*WaitGroupWrapper).RunWithRecover.func1\n\t/workspace/source/tidb/pkg/util/wait_group_wrapper.go:189"]
[2024/12/05 13:16:39.140 +00:00] [INFO] [coprocessor.go:1380] ["[TIME_COP_PROCESS] resp_time:667.732496ms txnStartTS:454401615058436099 region_id:343420 store_addr:tc-tikv-0.tc-tikv-peer.forge5-tps-7691514-1-39.svc:20160 stats:Cop:{num_rpc:1, total_time:667.7ms} kv_process_ms:666 kv_wait_ms:0 kv_read_ms:604 processed_versions:817699 total_versions:817764 rocksdb_delete_skipped_count:182683 rocksdb_key_skipped_count:1118101 rocksdb_cache_hit_count:7563 rocksdb_read_count:0 rocksdb_read_byte:0"]
[2024/12/05 13:16:39.826 +00:00] [INFO] [coprocessor.go:1380] ["[TIME_COP_PROCESS] resp_time:684.813268ms txnStartTS:454401615228829698 region_id:343420 store_addr:tc-tikv-0.tc-tikv-peer.forge5-tps-7691514-1-39.svc:20160 stats:Cop:{num_rpc:1, total_time:684.8ms} kv_process_ms:683 kv_wait_ms:0 kv_read_ms:624 processed_versions:817699 total_versions:817764 rocksdb_delete_skipped_count:182683 rocksdb_key_skipped_count:1118101 rocksdb_cache_hit_count:7563 rocksdb_read_count:0 rocksdb_read_byte:0"]
[2024/12/05 13:16:39.826 +00:00] [INFO] [refresher.go:156] ["Auto analyze triggered"] [category=stats] [job="NonPartitionedTableAnalysisJob:\n\tAnalyzeType: analyzeIndex\n\tIndexes: k_2, ek1, ek2, ek3, ek4, ek5, ek6\n\tSchema: sbtest582329\n\tTable: sbtest2\n\tTableID: 4562008\n\tTableStatsVer: 210000\n\tChangePercentage: 1.000000\n\tTableSize: 140000.00\n\tLastAnalysisDuration: 173h5m36.56s\n\tWeight: 3.657332\n"]
[2024/12/05 13:16:39.826 +00:00] [INFO] [worker.go:91] ["Job submitted"] [category=stats] [job="NonPartitionedTableAnalysisJob:\n\tAnalyzeType: analyzeIndex\n\tIndexes: k_2, ek1, ek2, ek3, ek4, ek5, ek6\n\tSchema: sbtest582329\n\tTable: sbtest2\n\tTableID: 4562008\n\tTableStatsVer: 210000\n\tChangePercentage: 1.000000\n\tTableSize: 140000.00\n\tLastAnalysisDuration: 173h5m36.56s\n\tWeight: 3.657332\n"]
[2024/12/05 13:16:39.826 +00:00] [WARN] [exec.go:98] ["panic in execAnalyzeStmt"] [error="runtime error: invalid memory address or nil pointer dereference"] [stack="github.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/exec.RunAnalyzeStmt.func1\n\t/workspace/source/tidb/pkg/statistics/handle/autoanalyze/exec/exec.go:98\nruntime.gopanic\n\t/usr/local/go/src/runtime/panic.go:785\nruntime.panicmem\n\t/usr/local/go/src/runtime/panic.go:262\nruntime.sigpanic\n\t/usr/local/go/src/runtime/signal_unix.go:917\ngithub.com/pingcap/tidb/pkg/util/sqlexec.GetExecOption\n\t/workspace/source/tidb/pkg/util/sqlexec/restricted_sql_executor.go:134\ngithub.com/pingcap/tidb/pkg/session.(*session).withRestrictedSQLExecutor\n\t/workspace/source/tidb/pkg/session/session.go:1933\ngithub.com/pingcap/tidb/pkg/session.(*session).ExecRestrictedSQL\n\t/workspace/source/tidb/pkg/session/session.go:1958\ngithub.com/pingcap/tidb/pkg/statistics/handle/util.ExecWithOpts\n\t/workspace/source/tidb/pkg/statistics/handle/util/util.go:263\ngithub.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/exec.RunAnalyzeStmt\n\t/workspace/source/tidb/pkg/statistics/handle/autoanalyze/exec/exec.go:102\ngithub.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/exec.AutoAnalyze\n\t/workspace/source/tidb/pkg/statistics/handle/autoanalyze/exec/exec.go:55\ngithub.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/priorityqueue.(*NonPartitionedTableAnalysisJob).analyzeIndexes\n\t/workspace/source/tidb/pkg/statistics/handle/autoanalyze/priorityqueue/non_partitioned_table_analysis_job.go:263\ngithub.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/priorityqueue.(*NonPartitionedTableAnalysisJob).Analyze.func2\n\t/workspace/source/tidb/pkg/statistics/handle/autoanalyze/priorityqueue/non_partitioned_table_analysis_job.go:105\ngithub.com/pingcap/tidb/pkg/statistics/handle/util.CallWithSCtx\n\t/workspace/source/tidb/pkg/statistics/handle/util/util.go:106\ngithub.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/priorityqueue.(*NonPartitionedTableAnalysisJob).Analyze\n\t/workspace/source/tidb/pkg/statistics/handle/autoanalyze/priorityqueue/non_partitioned_table_analysis_job.go:100\ngithub.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/refresher.(*worker).processJob\n\t/workspace/source/tidb/pkg/statistics/handle/autoanalyze/refresher/worker.go:102\ngithub.com/pingcap/tidb/pkg/statistics/handle/autoanalyze/refresher.(*worker).SubmitJob.func1\n\t/workspace/source/tidb/pkg/statistics/handle/autoanalyze/refresher/worker.go:83\ngithub.com/pingcap/tidb/pkg/util.(*WaitGroupWrapper).RunWithRecover.func1\n\t/workspace/source/tidb/pkg/util/wait_group_wrapper.go:189"]

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

3. What did you see instead (Required)

4. What is your TiDB version? (Required)

Release Version: v8.5.0-alpha-279-g9812d85d0d
Edition: Community
Git Commit Hash: 9812d85
Git Branch: HEAD
UTC Build Time: 2024-12-03 17:04:33
GoVersion: go1.23.3
Race Enabled: false
Check Table Before Drop: false
Store: unistore

@lilinghai lilinghai added the type/bug The issue is confirmed as a bug. label Dec 5, 2024
@Rustin170506 Rustin170506 self-assigned this Dec 5, 2024
@Rustin170506
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-8.5 This bug affects the 8.5.x(LTS) versions. impact/panic severity/critical sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants