Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

planner: fix DATA RACE caused by TestTiDBBindingInListToVer175 #48966

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pkg/session/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2816,6 +2816,7 @@ func upgradeToVer175(s sessiontypes.Session, ver int64) {
return
}
req := rs.NewChunk(nil)
updateStmts := make([]string, 0, 4)
for {
err = rs.Next(ctx, req)
if err != nil {
Expand All @@ -2832,13 +2833,18 @@ func upgradeToVer175(s sessiontypes.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 sessiontypes.Session, ver int64) {
Expand Down