diff --git a/app/vmselect/promql/rollup.go b/app/vmselect/promql/rollup.go index 58d0c64490..cf524f90b7 100644 --- a/app/vmselect/promql/rollup.go +++ b/app/vmselect/promql/rollup.go @@ -1893,6 +1893,10 @@ func rollupChangesPrometheus(rfa *rollupFuncArg) float64 { n := 0 for _, v := range values[1:] { if v != prevValue { + if math.Abs(v-prevValue) < 1e-12*math.Abs(v) { + // This may be precision error. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/767#issuecomment-1650932203 + continue + } n++ prevValue = v } @@ -1916,6 +1920,10 @@ func rollupChanges(rfa *rollupFuncArg) float64 { } for _, v := range values { if v != prevValue { + if math.Abs(v-prevValue) < 1e-12*math.Abs(v) { + // This may be precision error. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/767#issuecomment-1650932203 + continue + } n++ prevValue = v } @@ -1944,6 +1952,10 @@ func rollupIncreases(rfa *rollupFuncArg) float64 { n := 0 for _, v := range values { if v > prevValue { + if math.Abs(v-prevValue) < 1e-12*math.Abs(v) { + // This may be precision error. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/767#issuecomment-1650932203 + continue + } n++ } prevValue = v @@ -1975,6 +1987,10 @@ func rollupResets(rfa *rollupFuncArg) float64 { n := 0 for _, v := range values { if v < prevValue { + if math.Abs(v-prevValue) < 1e-12*math.Abs(v) { + // This may be precision error. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/767#issuecomment-1650932203 + continue + } n++ } prevValue = v diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index ef7126bc82..c97143ae71 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -14,6 +14,7 @@ The following `tip` changes can be tested by building VictoriaMetrics components * SECURITY: upgrade Go builder from Go1.21.6 to Go1.21.7. See [the list of issues addressed in Go1.21.7](https://github.com/golang/go/issues?q=milestone%3AGo1.21.7+label%3ACherryPickApproved). * BUGFIX: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): properly propagate [label filters](https://docs.victoriametrics.com/keyconcepts/#filtering) from multiple arguments passed to [aggregate functions](https://docs.victoriametrics.com/metricsql/#aggregate-functions). For example, `sum({job="foo"}, {job="bar"}) by (job) + a` was improperly optimized to `sum({job="foo"}, {job="bar"}) by (job) + a{job="foo"}` before being executed. This could lead to unexpected results. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5604). +* BUGFIX: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): properly handle precision errors when calculating [changes](https://docs.victoriametrics.com/metricsql/#changes), [changes_prometheus](https://docs.victoriametrics.com/metricsql/#changes_prometheus), [increases_over_time](https://docs.victoriametrics.com/metricsql/#increases_over_time) and [resets](https://docs.victoriametrics.com/metricsql/#resets) functions. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/767). ## [v1.93.11](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.93.11)