Skip to content

Commit

Permalink
statistics: fix data race (pingcap#32448)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrysan authored Feb 18, 2022
1 parent d20be03 commit c102b6b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion statistics/handle/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type statsCache struct {
// Handle can update stats info periodically.
type Handle struct {
mu struct {
sync.Mutex
sync.RWMutex
ctx sessionctx.Context
// rateMap contains the error rate delta from feedback.
rateMap errorRateDeltaMap
Expand Down
2 changes: 2 additions & 0 deletions statistics/handle/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,9 @@ func (h *Handle) autoAnalyzeTable(tblInfo *model.TableInfo, statsTbl *statistics
}

func (h *Handle) autoAnalyzePartitionTable(tblInfo *model.TableInfo, pi *model.PartitionInfo, db string, start, end time.Time, ratio float64) bool {
h.mu.RLock()
tableStatsVer := h.mu.ctx.GetSessionVars().AnalyzeVersion
h.mu.RUnlock()
partitionNames := make([]interface{}, 0, len(pi.Definitions))
for _, def := range pi.Definitions {
partitionStatsTbl := h.GetPartitionStats(tblInfo, def.ID)
Expand Down

0 comments on commit c102b6b

Please sign in to comment.