Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix race when checking for dirty aggregations #3886

Merged
merged 9 commits into from
Nov 3, 2021
4 changes: 3 additions & 1 deletion src/aggregator/aggregation/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ func isExpensive(aggTypes aggregation.Types) bool {
return false
}

func maybeReplaceAnnotation(currentAnnotation, newAnnotation []byte) []byte {
// MaybeReplaceAnnotation replaces the current annotation with the new annotation, returning the updated ref for
// current annotation.
func MaybeReplaceAnnotation(currentAnnotation, newAnnotation []byte) []byte {
if len(newAnnotation) == 0 {
return currentAnnotation
}
Expand Down
2 changes: 1 addition & 1 deletion src/aggregator/aggregation/counter.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (c *Counter) Update(timestamp time.Time, value int64, annotation []byte) {
c.sumSq += value * value
}

c.annotation = maybeReplaceAnnotation(c.annotation, annotation)
c.annotation = MaybeReplaceAnnotation(c.annotation, annotation)
}

// LastAt returns the time of the last value received.
Expand Down
2 changes: 1 addition & 1 deletion src/aggregator/aggregation/gauge.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func NewGauge(opts Options) Gauge {

// Update updates the gauge value.
func (g *Gauge) Update(timestamp time.Time, value float64, annotation []byte) {
g.annotation = maybeReplaceAnnotation(g.annotation, annotation)
g.annotation = MaybeReplaceAnnotation(g.annotation, annotation)
g.updateTotals(timestamp, value)
// min/max cannot be updated by an update to a value.
if math.IsNaN(g.max) || g.max < value {
Expand Down
2 changes: 1 addition & 1 deletion src/aggregator/aggregation/timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (t *Timer) AddBatch(timestamp time.Time, values []float64, annotation []byt

t.stream.AddBatch(values)

t.annotation = maybeReplaceAnnotation(t.annotation, annotation)
t.annotation = MaybeReplaceAnnotation(t.annotation, annotation)
}

func (t *Timer) recordLastAt(timestamp time.Time) {
Expand Down
Loading