From 5fd79f47f17e7f23d74fc5e7f6c65e5ffc309718 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 2 Oct 2023 20:06:46 +0200 Subject: [PATCH] app/vmselect/promql: follow-up for 896c85a4a4acb328d3435a2b14ee3120ee2c738b - Clarify the description of the change at docs/CHANGELOG.md - Make sure that bitmap_*(X, NaN) returns NaN Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4996 Updates https://github.com/VictoriaMetrics/VictoriaMetrics/pull/5021 --- app/vmselect/promql/exec_test.go | 14 ++++++++------ app/vmselect/promql/transform.go | 8 +++++--- docs/CHANGELOG.md | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/vmselect/promql/exec_test.go b/app/vmselect/promql/exec_test.go index cf1c97c9cd..c393dbd580 100644 --- a/app/vmselect/promql/exec_test.go +++ b/app/vmselect/promql/exec_test.go @@ -259,8 +259,12 @@ func TestExecSuccess(t *testing.T) { t.Run("bitmap_and(NaN, 1)", func(t *testing.T) { t.Parallel() q := `bitmap_and(NaN, 1)` - var resultExpected []netstorage.Result - f(q, resultExpected) + f(q, nil) + }) + t.Run("bitmap_and(1, NaN)", func(t *testing.T) { + t.Parallel() + q := `bitmap_and(1, NaN)` + f(q, nil) }) t.Run("bitmap_and(round(rand(1) > 0.5, 1), 1)", func(t *testing.T) { t.Parallel() @@ -298,8 +302,7 @@ func TestExecSuccess(t *testing.T) { t.Run("bitmap_or(NaN, 1)", func(t *testing.T) { t.Parallel() q := `bitmap_or(NaN, 1)` - var resultExpected []netstorage.Result - f(q, resultExpected) + f(q, nil) }) t.Run("bitmap_or(round(rand(1) > 0.5, 1), 1)", func(t *testing.T) { t.Parallel() @@ -337,8 +340,7 @@ func TestExecSuccess(t *testing.T) { t.Run("bitmap_xor(NaN, 1)", func(t *testing.T) { t.Parallel() q := `bitmap_xor(NaN, 1)` - var resultExpected []netstorage.Result - f(q, resultExpected) + f(q, nil) }) t.Run("bitmap_xor(round(rand(1) > 0.5, 1), 1)", func(t *testing.T) { t.Parallel() diff --git a/app/vmselect/promql/transform.go b/app/vmselect/promql/transform.go index 64b4f59b9d..d61acf08be 100644 --- a/app/vmselect/promql/transform.go +++ b/app/vmselect/promql/transform.go @@ -2590,10 +2590,12 @@ func newTransformBitmap(bitmapFunc func(a, b uint64) uint64) func(tfa *transform } tf := func(values []float64) { for i, v := range values { - if math.IsNaN(v) { - continue + w := ns[i] + result := nan + if !math.IsNaN(v) && !math.IsNaN(w) { + result = float64(bitmapFunc(uint64(v), uint64(w))) } - values[i] = float64(bitmapFunc(uint64(v), uint64(ns[i]))) + values[i] = result } } return doTransformValues(args[0], tf, tfa.fe) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 50490d42e5..7c7c1767e3 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -54,13 +54,13 @@ The sandbox cluster installation is running under the constant load generated by * FEATURE: limit the length of string params in log messages to 500 chars. Longer string params are replaced with the `first_250_chars..last_250_chars`. This prevents from too long log lines, which can be emitted by VictoriaMetrics components. * FEATURE: [docker compose environment](https://github.com/VictoriaMetrics/VictoriaMetrics/tree/master/deployment/docker): add `vmauth` component to cluster's docker-compose example for balancing load among multiple `vmselect` components. * FEATURE: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): make sure that `q2` series are returned after `q1` series in the results of `q1 or q2` query, in the same way as Prometheus does. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4763). +* FEATURE: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): return empty result from [`bitmap_and(a, b)`](https://docs.victoriametrics.com/MetricsQL.html#bitmap_and), [`bitmap_or(a, b)`](https://docs.victoriametrics.com/MetricsQL.html#bitmap_or) and [`bitmap_xor(a, b)`](https://docs.victoriametrics.com/MetricsQL.html#bitmap_xor) if `a` or `b` have no value at the particular timestamp. Previously `0` was returned in this case. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4996). * FEATURE: stop exposing `vm_merge_need_free_disk_space` metric, since it has been appeared that it confuses users while doesn't bring any useful information. See [this comment](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/686#issuecomment-1733844128). * BUGFIX: [Official Grafana dashboards for VictoriaMetrics](https://grafana.com/orgs/victoriametrics): fix display of ingested rows rate for `Samples ingested/s` and `Samples rate` panels for vmagent's dasbhoard. Previously, not all ingested protocols were accounted in these panels. An extra panel `Rows rate` was added to `Ingestion` section to display the split for rows ingested rate by protocol. * BUGFIX: [Official Grafana dashboards for VictoriaMetrics](https://grafana.com/orgs/victoriametrics): move vmagent's `Concurrent inserts` panel to Troubleshooting section from `Ingestion` section because this panel is related to both: scraped and ingested data. Before, it could have give a misleading impression that it is related to ingested metrics only. * BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): fix the bug causing render looping when switching to heatmap. * BUGFIX: [VictoriaMetrics enterprise](https://docs.victoriametrics.com/enterprise.html) validate `-dedup.minScrapeInterval` value and `-downsampling.period` intervals are multiples of each other. See [these docs](https://docs.victoriametrics.com/#downsampling). -* BUGFIX: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): fix bitmap_*() functions behavior. These functions will return `NaN` if timeseries has no value for timestamp. Previously these functions return `0`. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4996). * BUGFIX: [vmbackup](https://docs.victoriametrics.com/vmbackup.html): properly copy `appliedRetention.txt` files inside `<-storageDataPath>/{data}` folders during [incremental backups](https://docs.victoriametrics.com/vmbackup.html#incremental-backups). Previously the new `appliedRetention.txt` could be skipped during incremental backups, which could lead to increased load on storage after restoring from backup. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5005). * BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): suppress `context canceled` error messages in logs when `vmagent` is reloading service discovery config. This error could appear starting from [v1.93.5](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.93.5). See [this PR](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/5048). * BUGFIX: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): allow passing [median_over_time](https://docs.victoriametrics.com/MetricsQL.html#median_over_time) to [aggr_over_time](https://docs.victoriametrics.com/MetricsQL.html#aggr_over_time). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5034).