Skip to content

Commit

Permalink
planner: handle panic when loading bindings at startup (#58017) (#58169)
Browse files Browse the repository at this point in the history
close #58016
  • Loading branch information
ti-chi-bot authored Dec 12, 2024
1 parent 17448cb commit b9d536d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/bindinfo/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ go_library(
"//pkg/util/stmtsummary/v2:stmtsummary",
"//pkg/util/table-filter",
"//pkg/util/timeutil",
"@com_github_pkg_errors//:errors",
"@org_golang_x_exp//maps",
"@org_uber_go_zap//:zap",
],
Expand Down
9 changes: 8 additions & 1 deletion pkg/bindinfo/bind_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/pingcap/tidb/pkg/types"
"github.com/pingcap/tidb/pkg/util/hack"
"github.com/pingcap/tidb/pkg/util/hint"
"github.com/pkg/errors"
)

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

// prepareHints builds ID and Hint for BindRecord. If sctx is not nil, we check if
// the BindSQL is still valid.
func (br *BindRecord) prepareHints(sctx sessionctx.Context) error {
func (br *BindRecord) prepareHints(sctx sessionctx.Context) (rerr error) {
defer func() {
if r := recover(); r != nil {
rerr = errors.Errorf("panic when preparing hints for binding, panic: %v", r)
}
}()

p := parser.New()
for i, bind := range br.Bindings {
if (bind.Hint != nil && bind.ID != "") || bind.Status == deleted {
Expand Down

0 comments on commit b9d536d

Please sign in to comment.