Skip to content

Commit

Permalink
lib/streamaggr: explicitly call resetSeries after flushSeries
Browse files Browse the repository at this point in the history
This makes the code less fragile
  • Loading branch information
valyala committed Mar 4, 2024
1 parent ac3cf3f commit 8649451
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/streamaggr/streamaggr.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ func (a *aggregator) flush(pushFunc PushFunc) {
ctx := getFlushCtx(a, pushFunc)
as.flushState(ctx)
ctx.flushSeries()
ctx.resetSeries()
putFlushCtx(ctx)
}(as)
}
Expand Down Expand Up @@ -925,8 +926,6 @@ func (ctx *flushCtx) flushSeries() {
}
auxLabels.Labels = dstLabels
promutils.PutLabels(auxLabels)

ctx.resetSeries()
}

func (ctx *flushCtx) appendSeries(key, suffix string, timestamp int64, value float64) {
Expand All @@ -948,6 +947,7 @@ func (ctx *flushCtx) appendSeries(key, suffix string, timestamp int64, value flo
// Limit the maximum length of ctx.tss in order to limit memory usage.
if len(ctx.tss) >= 10_000 {
ctx.flushSeries()
ctx.resetSeries()
}
}

Expand Down

0 comments on commit 8649451

Please sign in to comment.