Skip to content

Commit 9db025d

Browse files
authored
planner: handle panic when loading bindings at startup (#58017) (#58035)
close #58016
1 parent 5a138ef commit 9db025d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pkg/bindinfo/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ go_library(
4545
"//pkg/util/table-filter",
4646
"@com_github_pingcap_errors//:errors",
4747
"@com_github_pingcap_failpoint//:failpoint",
48+
"@com_github_pkg_errors//:errors",
4849
"@org_golang_x_sync//singleflight",
4950
"@org_uber_go_zap//:zap",
5051
],

pkg/bindinfo/binding.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/pingcap/tidb/pkg/sessionctx"
2424
"github.com/pingcap/tidb/pkg/types"
2525
"github.com/pingcap/tidb/pkg/util/hint"
26+
"github.com/pkg/errors"
2627
)
2728

2829
const (
@@ -130,7 +131,13 @@ func HasAvailableBinding(br Bindings) bool {
130131

131132
// prepareHints builds ID and Hint for Bindings. If sctx is not nil, we check if
132133
// the BindSQL is still valid.
133-
func prepareHints(sctx sessionctx.Context, binding *Binding) error {
134+
func prepareHints(sctx sessionctx.Context, binding *Binding) (rerr error) {
135+
defer func() {
136+
if r := recover(); r != nil {
137+
rerr = errors.Errorf("panic when preparing hints for binding %v, panic: %v", binding.BindSQL, r)
138+
}
139+
}()
140+
134141
p := parser.New()
135142
if (binding.Hint != nil && binding.ID != "") || binding.Status == deleted {
136143
return nil

0 commit comments

Comments
 (0)