Skip to content

Commit b9d536d

Browse files
authored
planner: handle panic when loading bindings at startup (#58017) (#58169)
close #58016
1 parent 17448cb commit b9d536d

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
@@ -37,6 +37,7 @@ go_library(
3737
"//pkg/util/stmtsummary/v2:stmtsummary",
3838
"//pkg/util/table-filter",
3939
"//pkg/util/timeutil",
40+
"@com_github_pkg_errors//:errors",
4041
"@org_golang_x_exp//maps",
4142
"@org_uber_go_zap//:zap",
4243
],

pkg/bindinfo/bind_record.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/pingcap/tidb/pkg/types"
2525
"github.com/pingcap/tidb/pkg/util/hack"
2626
"github.com/pingcap/tidb/pkg/util/hint"
27+
"github.com/pkg/errors"
2728
)
2829

2930
const (
@@ -172,7 +173,13 @@ func (br *BindRecord) FindBinding(hint string) *Binding {
172173

173174
// prepareHints builds ID and Hint for BindRecord. If sctx is not nil, we check if
174175
// the BindSQL is still valid.
175-
func (br *BindRecord) prepareHints(sctx sessionctx.Context) error {
176+
func (br *BindRecord) prepareHints(sctx sessionctx.Context) (rerr error) {
177+
defer func() {
178+
if r := recover(); r != nil {
179+
rerr = errors.Errorf("panic when preparing hints for binding, panic: %v", r)
180+
}
181+
}()
182+
176183
p := parser.New()
177184
for i, bind := range br.Bindings {
178185
if (bind.Hint != nil && bind.ID != "") || bind.Status == deleted {

0 commit comments

Comments
 (0)