Skip to content

Commit 7ee327f

Browse files
authored
planner: handle panic when loading bindings at startup (#58017) (#59062)
close #58016
1 parent 0bfb501 commit 7ee327f

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.4.1

bindinfo/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ go_library(
3737
"//util/stmtsummary",
3838
"//util/table-filter",
3939
"//util/timeutil",
40+
"@com_github_pingcap_errors//:errors",
4041
"@org_golang_x_exp//maps",
4142
"@org_uber_go_zap//:zap",
4243
],

bindinfo/bind_record.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"time"
1919
"unsafe"
2020

21+
"github.com/pingcap/errors"
2122
"github.com/pingcap/tidb/metrics"
2223
"github.com/pingcap/tidb/parser"
2324
"github.com/pingcap/tidb/sessionctx"
@@ -161,7 +162,13 @@ func (br *BindRecord) FindBinding(hint string) *Binding {
161162

162163
// prepareHints builds ID and Hint for BindRecord. If sctx is not nil, we check if
163164
// the BindSQL is still valid.
164-
func (br *BindRecord) prepareHints(sctx sessionctx.Context) error {
165+
func (br *BindRecord) prepareHints(sctx sessionctx.Context) (rerr error) {
166+
defer func() {
167+
if r := recover(); r != nil {
168+
rerr = errors.Errorf("panic when preparing hints for binding panic: %v", r)
169+
}
170+
}()
171+
165172
p := parser.New()
166173
for i, bind := range br.Bindings {
167174
if (bind.Hint != nil && bind.ID != "") || bind.Status == deleted {

0 commit comments

Comments
 (0)