Skip to content

Commit 24476a1

Browse files
authored
planner: fix DATA RACE caused by TestTiDBBindingInListToVer175 (#48966) (#48982)
close #48953
1 parent 5a30f1f commit 24476a1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/session/bootstrap.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2814,6 +2814,7 @@ func upgradeToVer175(s Session, ver int64) {
28142814
return
28152815
}
28162816
req := rs.NewChunk(nil)
2817+
updateStmts := make([]string, 0, 4)
28172818
for {
28182819
err = rs.Next(ctx, req)
28192820
if err != nil {
@@ -2830,13 +2831,18 @@ func upgradeToVer175(s Session, ver int64) {
28302831
if originalNormalizedSQL == newNormalizedSQL {
28312832
continue // no need to update
28322833
}
2833-
mustExecute(s, fmt.Sprintf("UPDATE mysql.bind_info SET original_sql='%s' WHERE original_sql='%s'", newNormalizedSQL, originalNormalizedSQL))
2834+
// must run those update statements outside this loop, otherwise may cause some concurrency problems,
2835+
// since the current statement over this session has not been finished yet.
2836+
updateStmts = append(updateStmts, fmt.Sprintf("UPDATE mysql.bind_info SET original_sql='%s' WHERE original_sql='%s'", newNormalizedSQL, originalNormalizedSQL))
28342837
}
28352838
req.Reset()
28362839
}
28372840
if err := rs.Close(); err != nil {
28382841
logutil.BgLogger().Fatal("upgradeToVer175 error", zap.Error(err))
28392842
}
2843+
for _, updateStmt := range updateStmts {
2844+
mustExecute(s, updateStmt)
2845+
}
28402846
}
28412847

28422848
func upgradeToVer176(s Session, ver int64) {

0 commit comments

Comments
 (0)