Skip to content

Commit

Permalink
planner: fix DATA RACE caused by TestTiDBBindingInListToVer175 (#48966)
Browse files Browse the repository at this point in the history
close #48953
  • Loading branch information
qw4990 committed Nov 28, 2023
1 parent 651e770 commit e116f6c
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 @@ -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

0 comments on commit e116f6c

Please sign in to comment.