Skip to content

Commit

Permalink
stmtsummary: fix data race in the stmtSummaryByDigestElement.authUsers (
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot committed Aug 16, 2023
1 parent a742996 commit 2bcc671
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions util/stmtsummary/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ go_library(
"//util/set",
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_tikv_client_go_v2//util",
"@org_golang_x_exp//maps",
"@org_golang_x_exp//slices",
"@org_uber_go_atomic//:atomic",
"@org_uber_go_zap//:zap",
Expand Down
4 changes: 3 additions & 1 deletion util/stmtsummary/statement_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/pingcap/tidb/util/plancodec"
"github.com/tikv/client-go/v2/util"
atomic2 "go.uber.org/atomic"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
)

Expand Down Expand Up @@ -403,8 +404,9 @@ func (ssMap *stmtSummaryByDigestMap) GetMoreThanCntBindableStmt(cnt int64) []*Bi
PlanHint: ssElement.planHint,
Charset: ssElement.charset,
Collation: ssElement.collation,
Users: ssElement.authUsers,
Users: make(map[string]struct{}),
}
maps.Copy(stmt.Users, ssElement.authUsers)
// If it is SQL command prepare / execute, the ssElement.sampleSQL is `execute ...`, we should get the original select query.
// If it is binary protocol prepare / execute, ssbd.normalizedSQL should be same as ssElement.sampleSQL.
if ssElement.prepared {
Expand Down

0 comments on commit 2bcc671

Please sign in to comment.