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
This commit is contained in:
Aliaksandr Valialkin 2021-08-14 12:40:27 +03:00
parent 6d53620adf
commit 73d7b568da

View file

@ -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
}
}
}