Skip to content

[Bug] statsItem.samplingInHour trims the wrong list, so csListDay grows without bound and day-level stats use an ever-growing window #1241

Description

@wang-jiahua

Describe the Bug

statsItem.samplingInHour() in consumer/statistics.go appends a snapshot to csListDay but trims csListHour:

si.csListDay.PushBack(callSnapshot{...})
if si.csListDay.Len() > 25 {
    si.csListHour.Remove(si.csListDay.Front())   // wrong list
}

container/list.Remove(e) is a no-op when e does not belong to that list, so nothing is ever removed: csListDay grows by one snapshot per hour per statsItem forever. The sibling methods samplingInSeconds/samplingInMinutes push and trim the same list, which shows this is a copy-paste slip.

Steps to Reproduce

Call samplingInHour() 30 times on a fresh statsItem; csListDay.Len() is 30 instead of the intended cap 25.

What Did You Expect to See?

csListDay capped at 25 entries (a ~25-hour sliding window for the day-level stats).

What Did You See Instead?

Unbounded growth (slow memory leak, one snapshot per hour per topic/group statsItem), and getStatsDataInDay() computes over an ever-growing window instead of the intended ~25-hour one, skewing day-level TPS/AVGPT.

Additional Context

Fix incoming: si.csListDay.Remove(si.csListDay.Front()), aligning with the sibling sampling methods; includes a regression test.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions