diff --git a/app/vmselect/promql/rollup.go b/app/vmselect/promql/rollup.go index be6ade1110..1c4946e752 100644 --- a/app/vmselect/promql/rollup.go +++ b/app/vmselect/promql/rollup.go @@ -1495,11 +1495,8 @@ func rollupDelta(rfa *rollupFuncArg) float64 { // See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/894 return values[len(values)-1] - rfa.realPrevValue } - // Assume that the previous non-existing value was 0 only in the following cases: - // - // - If the delta with the next value equals to 0. - // This is the case for slow-changing counter - see https://github.com/VictoriaMetrics/VictoriaMetrics/issues/962 - // - If the first value doesn't exceed too much the delta with the next value. + // Assume that the previous non-existing value was 0 + // only if the first value doesn't exceed too much the delta with the next value. // // This should prevent from improper increase() results for os-level counters // such as cpu time or bytes sent over the network interface. @@ -1513,9 +1510,6 @@ func rollupDelta(rfa *rollupFuncArg) float64 { } else if !math.IsNaN(rfa.realNextValue) { d = rfa.realNextValue - values[0] } - if d == 0 { - d = 10 - } if math.Abs(values[0]) < 10*(math.Abs(d)+1) { prevValue = 0 } else { diff --git a/app/vmselect/promql/rollup_test.go b/app/vmselect/promql/rollup_test.go index ae33628145..806398c1e5 100644 --- a/app/vmselect/promql/rollup_test.go +++ b/app/vmselect/promql/rollup_test.go @@ -1425,19 +1425,16 @@ func TestRollupDelta(t *testing.T) { // Small initial value f(nan, nan, nan, []float64{1}, 1) - f(nan, nan, nan, []float64{10}, 10) - f(nan, nan, nan, []float64{100}, 100) + f(nan, nan, nan, []float64{10}, 0) + f(nan, nan, nan, []float64{100}, 0) f(nan, nan, nan, []float64{1, 2, 3}, 3) f(1, nan, nan, []float64{1, 2, 3}, 2) f(nan, nan, nan, []float64{5, 6, 8}, 8) f(2, nan, nan, []float64{5, 6, 8}, 6) - // Moderate initial value with zero delta after that. - // See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/962 - f(nan, nan, nan, []float64{100}, 100) - f(nan, nan, nan, []float64{100, 100}, 100) + f(nan, nan, nan, []float64{100, 100}, 0) - // Big initial value with with zero delta after that. + // Big initial value with zero delta after that. f(nan, nan, nan, []float64{1000}, 0) f(nan, nan, nan, []float64{1000, 1000}, 0)