Skip to content

Commit

Permalink
planner: fix DATA RACE caused by TestDropBindBySQLDigest (#49164)
Browse files Browse the repository at this point in the history
close #49113
  • Loading branch information
qw4990 authored Dec 5, 2023
1 parent 2aa35f0 commit 555048b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pkg/bindinfo/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ func (h *BindHandle) Update(fullLoad bool) (err error) {
if !fullLoad {
timeCondition = fmt.Sprintf("WHERE update_time>'%s'", lastUpdateTime.String())
}
h.sctx.Lock()
defer h.sctx.Unlock()

// No need to acquire the session context lock for ExecRestrictedSQL, it
// uses another background session.
selectStmt := fmt.Sprintf(`SELECT original_sql, bind_sql, default_db, status, create_time,
update_time, charset, collation, source, sql_digest, plan_digest FROM mysql.bind_info
%s ORDER BY update_time, create_time`, timeCondition)
Expand Down Expand Up @@ -654,8 +654,6 @@ func (h *BindHandle) newBindRecord(row chunk.Row) (string, *BindRecord, error) {
Bindings: []Binding{hint},
}
sqlDigest := parser.DigestNormalized(bindRecord.OriginalSQL)
h.sctx.Lock()
defer h.sctx.Unlock()
h.sctx.GetSessionVars().CurrentDB = bindRecord.Db
err := bindRecord.prepareHints(h.sctx.Context)
return sqlDigest.String(), bindRecord, err
Expand Down

0 comments on commit 555048b

Please sign in to comment.