Skip to content

Commit

Permalink
planner: fix DATA RACE caused by TestTiDBBindingInListToVer175 (#48966)…
Browse files Browse the repository at this point in the history
… (#48982)

close #48953
  • Loading branch information
ti-chi-bot authored Dec 5, 2023
1 parent 5a30f1f commit 24476a1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/session/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2814,6 +2814,7 @@ func upgradeToVer175(s Session, ver int64) {
return
}
req := rs.NewChunk(nil)
updateStmts := make([]string, 0, 4)
for {
err = rs.Next(ctx, req)
if err != nil {
Expand All @@ -2830,13 +2831,18 @@ func upgradeToVer175(s Session, ver int64) {
if originalNormalizedSQL == newNormalizedSQL {
continue // no need to update
}
mustExecute(s, fmt.Sprintf("UPDATE mysql.bind_info SET original_sql='%s' WHERE original_sql='%s'", newNormalizedSQL, originalNormalizedSQL))
// must run those update statements outside this loop, otherwise may cause some concurrency problems,
// since the current statement over this session has not been finished yet.
updateStmts = append(updateStmts, fmt.Sprintf("UPDATE mysql.bind_info SET original_sql='%s' WHERE original_sql='%s'", newNormalizedSQL, originalNormalizedSQL))
}
req.Reset()
}
if err := rs.Close(); err != nil {
logutil.BgLogger().Fatal("upgradeToVer175 error", zap.Error(err))
}
for _, updateStmt := range updateStmts {
mustExecute(s, updateStmt)
}
}

func upgradeToVer176(s Session, ver int64) {
Expand Down

0 comments on commit 24476a1

Please sign in to comment.