From 73d7b568da706de475471f3e064380257221e72e Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Sat, 14 Aug 2021 12:40:27 +0300 Subject: [PATCH] app/vmselect/promql: properly handle Prometheus staleness marks in removeCounterResets functions Prometheus stalenss marks shouldn't be changed in removeCounterResets. Otherwise they will be converted to an ordinary NaN values, which couldn't be removed in dropStaleNaNs() function later. This may result in incorrect calculations for rollup functions. Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1526 --- app/vmselect/promql/rollup.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/vmselect/promql/rollup.go b/app/vmselect/promql/rollup.go index 6c999a93c9..95f6764756 100644 --- a/app/vmselect/promql/rollup.go +++ b/app/vmselect/promql/rollup.go @@ -704,8 +704,6 @@ func getMaxPrevInterval(scrapeInterval int64) int64 { } func removeCounterResets(values []float64) { - // There is no need in handling NaNs here, since they are impossible - // on values from vmstorage. if len(values) == 0 { return } @@ -723,7 +721,9 @@ func removeCounterResets(values []float64) { } } prevValue = v - values[i] = v + correction + if !decimal.IsStaleNaN(v) { + values[i] = v + correction + } } }