VictoriaMetrics/app/vmselect/promql
Zakhar Bessarab dea3eb20cb
app/vmselect/promql: fix panic with using @ with series which is not present at the start of the query (#8445)
### Describe Your Changes

Previously, "selector @ another_selector" assumed that
"another_selector" metric is supposed to exist since "start" used in the
query.

If the query was evaluated in the following case (timestamps):
- start - 2, end - 10
- "another_selector" 5,6,7,8,9,10
- "selector" The resulting "at" timestamp would be taken from NaN (as
`int64(NaN * 1000)`), causing a panic or invalid behavior later.

Note that type cast of `NaN` to int64 is also platform-dependent, so
value of `int64(math.NaN() * 1000)` can produce `0` or max int64 on
different platforms and versions of Go.

This commit changes this and checks for the first non-NaN value. This
makes it easier to use for users as series are not always aligned and
returning an error in this case would disallow using this for some time
ranges.

See: https://github.com/VictoriaMetrics/VictoriaMetrics/issues/8444

### Checklist

The following checks are **mandatory**:

- [x] My change adheres [VictoriaMetrics contributing
guidelines](https://docs.victoriametrics.com/contributing/).

---------

Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>
Signed-off-by: hagen1778 <roman@victoriametrics.com>
Co-authored-by: hagen1778 <roman@victoriametrics.com>
(cherry picked from commit 7dfaef9088)
2025-03-06 16:42:51 +01:00
..
active_queries.go vmselect: add support of multi-tenant queries (#6346) 2024-10-01 16:37:18 +02:00
aggr.go make: bump golangci-lint to v1.63.4 ( 2025-01-13 07:23:21 +01:00
aggr_incremental.go app/vmselect/promql/aggr_incremental.go: eliminate unnecessary memory allocation in incrementalAggrFuncContext.updateTimeseries 2024-01-23 02:29:13 +02:00
aggr_incremental_test.go app/vmselect/promql: fix TestIncrementalAggr test on systems less than 3 CPU cores 2023-03-20 20:37:44 -07:00
aggr_test.go app/vmselect/promql: simplify the code after 388d020b7c 2024-01-16 22:35:51 +02:00
binary_op.go app/vmselect/promql: fix discrepancies when using or binary operator 2025-02-01 22:31:55 +01:00
eval.go app/vmselect/promql: fix panic with using @ with series which is not present at the start of the query (#8445) 2025-03-06 16:42:51 +01:00
eval_test.go vmselect: add support of multi-tenant queries (#6346) 2024-10-01 16:37:18 +02:00
exec.go app/vmselect/promql: improve performance of parseCache on systems with many CPU cores 2025-01-02 17:47:54 +01:00
exec_test.go app/vmselect/promql: fix discrepancies when using or binary operator 2025-02-01 22:31:55 +01:00
memory_limiter.go app/vmselect: return back the logic for limits the amounts of memory occupied by concurrently executed queries if -search.maxMemoryPerQuery isn't set 2022-10-10 21:54:18 +03:00
memory_limiter_test.go app/vmselect: return back the logic for limits the amounts of memory occupied by concurrently executed queries if -search.maxMemoryPerQuery isn't set 2022-10-10 21:54:18 +03:00
parse_cache.go app/vmselect/promql: improve performance of parseCache on systems with many CPU cores 2025-01-02 17:47:54 +01:00
parse_cache_test.go app/vmselect/promql: improve performance of parseCache on systems with many CPU cores 2025-01-02 17:47:54 +01:00
parse_cache_timing_test.go app/vmselect/promql: improve performance of parseCache on systems with many CPU cores 2025-01-02 17:47:54 +01:00
parser.go all: add support for or filters in series selectors 2023-07-15 23:56:18 -07:00
rollup.go bugfix: negative rate result when lookbehind window longer than search.maxLookback (#8378) 2025-02-27 22:55:32 +01:00
rollup_result_cache.go app/vmselect: fix panic/incorrect tenant in key 2024-11-25 11:47:24 +01:00
rollup_result_cache_test.go vmselect: add support of multi-tenant queries (#6346) 2024-10-01 16:37:18 +02:00
rollup_test.go app/vmselect/promql: respect staleness in removeCounterResets (#8073) 2025-01-24 07:52:51 +01:00
rollup_timing_test.go app/vmselect: use consistent randomizer in tests 2023-01-23 19:27:40 -08:00
timeseries.go vmselect: add support of multi-tenant queries (#6346) 2024-10-01 16:37:18 +02:00
timeseries_test.go app/vmselect/promql: use unsafe.Slice instead of deprecated reflect.SliceHeader 2024-02-29 17:51:16 +02:00
transform.go app/vmselect/promql: consistently replace NaN data points with non-NaN values for range_first and range_last functions 2024-09-23 15:00:05 +02:00
transform_test.go app/vmseleсt/promql: fix calculation of histogram buckets 2024-08-15 10:13:54 +02:00
tzdata.go all: cleanup: remove // +build ... lines, since they are no longer needed after Go1.17, and the minimum supported Go version for VictoriaMetrics source code is Go1.20 2023-11-13 19:15:42 +01:00