wang-jiahua opened a new issue, #1241:
URL: https://github.com/apache/rocketmq-client-go/issues/1241
### Describe the Bug
`statsItem.samplingInHour()` in `consumer/statistics.go` appends a snapshot
to `csListDay` but trims `csListHour`:
```go
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]