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

tidb can not restart after create global binding #40368

Closed
aytrack opened this issue Jan 6, 2023 · 1 comment · Fixed by #40402
Closed

tidb can not restart after create global binding #40368

aytrack opened this issue Jan 6, 2023 · 1 comment · Fixed by #40402
Assignees

Comments

@aytrack
Copy link
Contributor

aytrack commented Jan 6, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. execute the sqls
create table t1(a int, b int, key (a)) partition by range (a) (partition p0 values less than (10), partition p1 values less than (20));
create global binding for select * from t1 using select * from t1 use index (a);
show global bindings;
  1. restart tidb node
  2. check the tidb_stderr.log

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

  1. tidb could restarted

3. What did you see instead (Required)

1.tidb can not restart

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x313b7ce]

goroutine 1 [running]:
github.com/pingcap/tidb/executor.(*Compiler).Compile.func1()
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/compiler.go:72 +0x445
panic({0x4318e40, 0x6ec6870})
    /usr/local/go/src/runtime/panic.go:884 +0x212
github.com/pingcap/tidb/statistics/handle.(*Handle).GetPartitionStats(0xc0003fdb80?, 0x4f8da00?, 0x4f72898?, {0x0?, 0xc0012ef05c?, 0x2?})
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/statistics/handle/handle.go:997 +0x2e
github.com/pingcap/tidb/statistics/handle.(*Handle).GetTableStats(...)
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/statistics/handle/handle.go:992
github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildDataSource(0xc000b384e0, {0x4fafbb0, 0xc0015c5920}, 0xc0012d5790, 0xc0015fa050)
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/logical_plan_builder.go:4456 +0x9ce
github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildResultSetNode(0xc000b384e0, {0x4fafbb0?, 0xc0015c5920?}, {0x4fc96b0?, 0xc0015fa000?}, 0xf0?)
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/logical_plan_builder.go:380 +0x19d
github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildJoin(0xc00166cf50?, {0x4fafbb0?, 0xc0015c5920?}, 0x2?)
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/logical_plan_builder.go:720 +0x71d
github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildResultSetNode(0x0?, {0x4fafbb0?, 0xc0015c5920?}, {0x4fc8948?, 0xc0015ee870?}, 0x0?)
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/logical_plan_builder.go:367 +0x271
github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildTableRefs(0xc000b384e0?, {0x4fafbb0?, 0xc0015c5920?}, 0x393d09e?)
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/logical_plan_builder.go:359 +0x85
github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildSelect(0xc000b384e0, {0x4fafbb0, 0xc0015c5920}, 0xc0015ea360)
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/logical_plan_builder.go:3916 +0x6c7
github.com/pingcap/tidb/planner/core.(*PlanBuilder).Build(0xc000b384e0, {0x4fafbb0, 0xc0015c5920}, {0x4fc4080?, 0xc0015ea360?})
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/planbuilder.go:804 +0x745
github.com/pingcap/tidb/planner.buildLogicalPlan({0x4fafbb0, 0xc0015c5920}, {0x501e818?, 0xc0003fdb80}, {0x4fc4080, 0xc0015ea360}, 0xc000b384e0)
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/optimize.go:461 +0x12f
github.com/pingcap/tidb/planner.optimize({0x4fafbb0, 0xc0015c5920}, {0x501e818?, 0xc0003fdb80}, {0x4fc4080?, 0xc0015ea360?}, {0x4fe5b50, 0xc0015c59b0})
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/optimize.go:382 +0x473
github.com/pingcap/tidb/planner.Optimize({0x4fafbb0, 0xc0015c5920}, {0x501e818, 0xc0003fdb80}, {0x4fc4080, 0xc0015ea360}, {0x4fe5b50, 0xc0015c59b0})
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/optimize.go:245 +0xf11
github.com/pingcap/tidb/planner/core.(*PlanBuilder).buildExplain(0xc000b50000, {0x4fafbb0, 0xc0015c5920}, 0xc0015fa070)
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/planbuilder.go:4783 +0xd9
github.com/pingcap/tidb/planner/core.(*PlanBuilder).Build(0xc000b50000, {0x4fafbb0, 0xc0015c5920}, {0x4fc2c80?, 0xc0015fa070?})
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/core/planbuilder.go:779 +0x432
github.com/pingcap/tidb/planner.buildLogicalPlan({0x4fafbb0, 0xc0015c5920}, {0x501e818?, 0xc0003fdb80}, {0x4fc2c80, 0xc0015fa070}, 0xc000b50000)
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/optimize.go:461 +0x12f
github.com/pingcap/tidb/planner.optimize({0x4fafbb0, 0xc0015c5920}, {0x501e818?, 0xc0003fdb80}, {0x4fc2c80?, 0xc0015fa070?}, {0x4fe5b50, 0xc0015c59b0})
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/optimize.go:382 +0x473
github.com/pingcap/tidb/planner.Optimize({0x4fafbb0, 0xc0015c5920}, {0x501e818, 0xc0003fdb80}, {0x4fc2c80, 0xc0015fa070}, {0x4fe5b50, 0xc0015c59b0})
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/planner/optimize.go:245 +0xf11
github.com/pingcap/tidb/executor.(*Compiler).Compile(0xc00166efc8, {0x4fafbb0, 0xc0015c5920}, {0x4fc8580, 0xc0015fa070?})
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/executor/compiler.go:116 +0x6f8
github.com/pingcap/tidb/session.(*session).ExecuteStmt(0xc0003fdb80, {0x4fafbb0, 0xc0015c5920}, {0x4fc8580?, 0xc0015fa070})
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/session/session.go:2171 +0x54e
github.com/pingcap/tidb/session.(*session).ExecuteInternal(0xc0003fdb80, {0x4fafbb0, 0xc0015c5920}, {0xc000869840, 0x3f}, {0x0, 0x0, 0x0})
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/session/session.go:1674 +0x3f2
github.com/pingcap/tidb/bindinfo.getHintsForSQL({0x501e818, 0xc0003fdb80}, {0xc000ccb300, 0x29})
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/bindinfo/handle.go:951 +0x177
github.com/pingcap/tidb/bindinfo.(*BindRecord).prepareHints(0xc0015d0bc0, {0x501e818, 0xc0003fdb80})
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/bindinfo/bind_record.go:178 +0x1e7
github.com/pingcap/tidb/bindinfo.(*BindHandle).newBindRecord(0xc00053bf00, {0xc0015de140?, 0x1?})
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/bindinfo/handle.go:723 +0xbcf
github.com/pingcap/tidb/bindinfo.(*BindHandle).Update(0xc00053bf00, 0x1)
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/bindinfo/handle.go:173 +0x6c5
github.com/pingcap/tidb/domain.(*Domain).LoadBindInfoLoop(0xc000bca000, {0x501e818, 0xc0003fdb80}, {0x501e818, 0xc000b26000})
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/domain/domain.go:1444 +0xe5
github.com/pingcap/tidb/session.BootstrapSession({0x4fd95f0, 0xc000ea44b0})
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/session/session.go:3301 +0x648
main.createStoreAndDomain()
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/tidb-server/main.go:314 +0x1cb
main.main()
    /home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/tidb-server/main.go:214 +0x2ca
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x313b7ce]

4. What is your TiDB version? (Required)

mysql> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                               |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v6.5.0
Edition: Community
Git Commit Hash: 706c3fa3c526cdba5b3e9f066b1a568fb96c56e3
Git Branch: heads/refs/tags/v6.5.0
UTC Build Time: 2022-12-27 03:50:44
GoVersion: go1.19.3
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
@aytrack aytrack added type/bug The issue is confirmed as a bug. sig/planner SIG: Planner severity/critical labels Jan 6, 2023
@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 may-affects-6.4 may-affects-6.5 labels Jan 6, 2023
@chrysan
Copy link
Contributor

chrysan commented Jan 6, 2023

This issue is imported by PR: https://github.com/pingcap/tidb/pull/37573/files#diff-3b47fd3bf2c33ae3a03037a65ed39df33a4ae73debe9cf6f5bb2f397508061a0R4379
explain format='hint' is run for all sqls in bindings during bootstrap, before stats handle is initialized.

@Yisaer Yisaer 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. labels Jan 9, 2023
@Yisaer Yisaer removed 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.0 This bug maybe affects 5.0.x versions. labels Jan 9, 2023
ti-chi-bot added a commit that referenced this issue Jan 17, 2023
@windtalker windtalker mentioned this issue Jan 19, 2023
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants