diff --git a/app/vmselect/promql/eval.go b/app/vmselect/promql/eval.go index 8bbfcb0c1..9526cca2e 100644 --- a/app/vmselect/promql/eval.go +++ b/app/vmselect/promql/eval.go @@ -764,10 +764,7 @@ func getRollupMemoryLimiter() *memoryLimiter { func evalRollupWithIncrementalAggregate(name string, iafc *incrementalAggrFuncContext, rss *netstorage.Results, rcs []*rollupConfig, preFunc func(values []float64, timestamps []int64), sharedTimestamps []int64, removeMetricGroup bool) ([]*timeseries, error) { err := rss.RunParallel(func(rs *netstorage.Result, workerID uint) error { - if name != "default_rollup" { - // Remove Prometheus staleness marks, so non-default rollup functions don't hit NaN values. - rs.Values, rs.Timestamps = dropStaleNaNs(rs.Values, rs.Timestamps) - } + rs.Values, rs.Timestamps = dropStaleNaNs(name, rs.Values, rs.Timestamps) preFunc(rs.Values, rs.Timestamps) ts := getTimeseries() defer putTimeseries(ts) @@ -801,10 +798,7 @@ func evalRollupNoIncrementalAggregate(name string, rss *netstorage.Results, rcs tss := make([]*timeseries, 0, rss.Len()*len(rcs)) var tssLock sync.Mutex err := rss.RunParallel(func(rs *netstorage.Result, workerID uint) error { - if name != "default_rollup" { - // Remove Prometheus staleness marks, so non-default rollup functions don't hit NaN values. - rs.Values, rs.Timestamps = dropStaleNaNs(rs.Values, rs.Timestamps) - } + rs.Values, rs.Timestamps = dropStaleNaNs(name, rs.Values, rs.Timestamps) preFunc(rs.Values, rs.Timestamps) for _, rc := range rcs { if tsm := newTimeseriesMap(name, sharedTimestamps, &rs.MetricName); tsm != nil { @@ -901,7 +895,13 @@ func toTagFilter(dst *storage.TagFilter, src *metricsql.LabelFilter) { dst.IsNegative = src.IsNegative } -func dropStaleNaNs(values []float64, timestamps []int64) ([]float64, []int64) { +func dropStaleNaNs(name string, values []float64, timestamps []int64) ([]float64, []int64) { + if name == "default_rollup" { + // Do not drop Prometheus staleness marks (aka stale NaNs) for default_rollup() function, + // since it uses them for Prometheus-style staleness detection. + return values, timestamps + } + // Remove Prometheus staleness marks, so non-default rollup functions don't hit NaN values. hasStaleSamples := false for _, v := range values { if decimal.IsStaleNaN(v) {