Skip to content

Commit

Permalink
remove unnecessary h.mu.Lock
Browse files Browse the repository at this point in the history
  • Loading branch information
xuyifangreeneyes committed Feb 7, 2023
1 parent 7fb79b5 commit 4b8436a
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 12 deletions.
2 changes: 0 additions & 2 deletions statistics/handle/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ func (h *Handle) gcTableStats(is infoschema.InfoSchema, physicalID int64) error
return errors.Trace(err)
}
}
h.mu.Lock()
tbl, ok := h.getTableByPhysicalID(is, physicalID)
h.mu.Unlock()
if !ok {
logutil.BgLogger().Info("remove stats in GC due to dropped table", zap.Int64("table_id", physicalID))
return errors.Trace(h.DeleteTableStatsFromKV([]int64{physicalID}))
Expand Down
6 changes: 0 additions & 6 deletions statistics/handle/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,7 @@ func (h *Handle) Update(is infoschema.InfoSchema, opts ...TableStatsOpt) error {
modifyCount := row.GetInt64(2)
count := row.GetInt64(3)
lastVersion = version
h.mu.Lock()
table, ok := h.getTableByPhysicalID(is, physicalID)
h.mu.Unlock()
if !ok {
logutil.BgLogger().Debug("unknown physical ID in stats meta table, maybe it has been dropped", zap.Int64("ID", physicalID))
deletedTableIDs = append(deletedTableIDs, physicalID)
Expand Down Expand Up @@ -670,9 +668,7 @@ func (h *Handle) MergePartitionStats2GlobalStatsByTableID(sc sessionctx.Context,
physicalID int64, isIndex int, histIDs []int64,
tablePartitionStats map[int64]*statistics.Table) (globalStats *GlobalStats, err error) {
// get the partition table IDs
h.mu.Lock()
globalTable, ok := h.getTableByPhysicalID(is, physicalID)
h.mu.Unlock()
if !ok {
err = errors.Errorf("unknown physical ID %d in stats meta table, maybe it has been dropped", physicalID)
return
Expand Down Expand Up @@ -742,9 +738,7 @@ func (h *Handle) mergePartitionStats2GlobalStats(sc sessionctx.Context,

for _, def := range globalTableInfo.Partition.Definitions {
partitionID := def.ID
h.mu.Lock()
partitionTable, ok := h.getTableByPhysicalID(is, partitionID)
h.mu.Unlock()
if !ok {
err = errors.Errorf("unknown physical ID %d in stats meta table, maybe it has been dropped", partitionID)
return
Expand Down
4 changes: 0 additions & 4 deletions statistics/handle/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -684,9 +684,7 @@ func (h *Handle) UpdateStatsByLocalFeedback(is infoschema.InfoSchema) {
OUTER:
for _, fbs := range feedback.Feedbacks {
for _, fb := range fbs {
h.mu.Lock()
table, ok := h.getTableByPhysicalID(is, fb.PhysicalID)
h.mu.Unlock()
if !ok {
continue
}
Expand Down Expand Up @@ -829,9 +827,7 @@ func (h *Handle) handleSingleHistogramUpdate(is infoschema.InfoSchema, rows []ch
err = errors.Trace(h.deleteOutdatedFeedback(physicalTableID, histID, isIndex))
}
}()
h.mu.Lock()
table, ok := h.getTableByPhysicalID(is, physicalTableID)
h.mu.Unlock()
// The table has been deleted.
if !ok {
return nil
Expand Down

0 comments on commit 4b8436a

Please sign in to comment.