Skip to content

Commit

Permalink
Better count calculation in HandleDDLEvent function
Browse files Browse the repository at this point in the history
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
  • Loading branch information
Rustin170506 committed Nov 29, 2023
1 parent bb47af0 commit acf1509
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/statistics/handle/ddl/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ func (h *ddlHandlerImpl) HandleDDLEvent(t *util.DDLEvent) error {
case model.ActionDropTablePartition:
globalTableInfo, droppedPartitionInfo := t.GetDropPartitionInfo()

delta := int64(0)
count := int64(0)
for _, def := range droppedPartitionInfo.Definitions {
// Get the count and modify count of the partition.
Expand All @@ -133,7 +132,6 @@ func (h *ddlHandlerImpl) HandleDDLEvent(t *util.DDLEvent) error {
zap.String("partition", def.Name.O),
)
} else {
delta -= stats.RealtimeCount
count += stats.RealtimeCount
}
// Always reset the partition stats.
Expand All @@ -142,6 +140,8 @@ func (h *ddlHandlerImpl) HandleDDLEvent(t *util.DDLEvent) error {
}
}
if count != 0 {
// Because we drop the partition, we should subtract the count from the global stats.
delta := -count
if err := h.statsWriter.UpdateStatsMetaDelta(
globalTableInfo.ID, count, delta,
); err != nil {
Expand Down

0 comments on commit acf1509

Please sign in to comment.