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 7d0e64dcc0
commit af4a306d7b

View file

@ -704,8 +704,6 @@ func getMaxPrevInterval(scrapeInterval int64) int64 {
} }
func removeCounterResets(values []float64) { func removeCounterResets(values []float64) {
// There is no need in handling NaNs here, since they are impossible
// on values from vmstorage.
if len(values) == 0 { if len(values) == 0 {
return return
} }
@ -723,7 +721,9 @@ func removeCounterResets(values []float64) {
} }
} }
prevValue = v prevValue = v
values[i] = v + correction if !decimal.IsStaleNaN(v) {
values[i] = v + correction
}
} }
} }