Skip to content

Commit e116f6c

Browse files
authored
planner: fix DATA RACE caused by TestTiDBBindingInListToVer175 (#48966)
close #48953
1 parent 651e770 commit e116f6c

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
@@ -2816,6 +2816,7 @@ func upgradeToVer175(s sessiontypes.Session, ver int64) {
28162816
return
28172817
}
28182818
req := rs.NewChunk(nil)
2819+
updateStmts := make([]string, 0, 4)
28192820
for {
28202821
err = rs.Next(ctx, req)
28212822
if err != nil {
@@ -2832,13 +2833,18 @@ func upgradeToVer175(s sessiontypes.Session, ver int64) {
28322833
if originalNormalizedSQL == newNormalizedSQL {
28332834
continue // no need to update
28342835
}
2835-
mustExecute(s, fmt.Sprintf("UPDATE mysql.bind_info SET original_sql='%s' WHERE original_sql='%s'", newNormalizedSQL, originalNormalizedSQL))
2836+
// must run those update statements outside this loop, otherwise may cause some concurrency problems,
2837+
// since the current statement over this session has not been finished yet.
2838+
updateStmts = append(updateStmts, fmt.Sprintf("UPDATE mysql.bind_info SET original_sql='%s' WHERE original_sql='%s'", newNormalizedSQL, originalNormalizedSQL))
28362839
}
28372840
req.Reset()
28382841
}
28392842
if err := rs.Close(); err != nil {
28402843
logutil.BgLogger().Fatal("upgradeToVer175 error", zap.Error(err))
28412844
}
2845+
for _, updateStmt := range updateStmts {
2846+
mustExecute(s, updateStmt)
2847+
}
28422848
}
28432849

28442850
func upgradeToVer176(s sessiontypes.Session, ver int64) {

0 commit comments

Comments
 (0)