diff --git a/statistics/handle/gc.go b/statistics/handle/gc.go index edfd9b5eef4fd..5cbba2c1063ce 100644 --- a/statistics/handle/gc.go +++ b/statistics/handle/gc.go @@ -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})) diff --git a/statistics/handle/handle.go b/statistics/handle/handle.go index 4b71e9cc60e39..7743c2338dcfa 100644 --- a/statistics/handle/handle.go +++ b/statistics/handle/handle.go @@ -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) @@ -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 @@ -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 diff --git a/statistics/handle/update.go b/statistics/handle/update.go index 11d3dd28c6139..8437eb57006b0 100644 --- a/statistics/handle/update.go +++ b/statistics/handle/update.go @@ -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 } @@ -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