diff --git a/app/vmstorage/transport/server.go b/app/vmstorage/transport/server.go index 945e35582..62b846d2a 100644 --- a/app/vmstorage/transport/server.go +++ b/app/vmstorage/transport/server.go @@ -1143,12 +1143,12 @@ var ( func (ctx *vmselectRequestCtx) getMaxMetrics() int { maxMetrics := ctx.sq.MaxMetrics - if maxMetrics <= 0 || maxMetrics > *maxMetricsPerSearch { - maxMetrics = *maxMetricsPerSearch + maxMetricsLimit := *maxMetricsPerSearch + if maxMetricsLimit <= 0 { + maxMetricsLimit = 2e9 } - if maxMetrics <= 0 { - // The limit is missing. - maxMetrics = 2e9 + if maxMetrics <= 0 || maxMetrics > maxMetricsLimit { + maxMetrics = maxMetricsLimit } return maxMetrics } diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 3e5df56c8..62043a5cb 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -17,6 +17,7 @@ The following tip changes can be tested by building VictoriaMetrics components f FEATURE: [vmalert](https://docs.victoriametrics.com/vmalert.html): add support for `alert_relabel_configs` option at `-notifier.config`. This option allows configuring relabeling rules for alerts before sending them to configured notifiers. See [these docs](https://docs.victoriametrics.com/vmalert.html#notifier-configuration-file) for details. +BUGFIX: properly propagate limits at `-search.max*` command-line flags from `vminsert` to `vmstorage`. The limits are `-search.maxUniqueTimeseries`, `-search.maxSeries`, `-search.maxFederateSeries`, `-search.maxExportSeries`, `-search.maxGraphiteSeries` and `-search.maxTSDBStatusSeries`. They weren't propagated to `vmstorage` because of the bug. These limits were introduced in [v1.76.0](https://docs.victoriametrics.com/CHANGELOG.html#v1760). BUGFIX: fix goroutine leak and possible deadlock when importing invalid data via [native binary format](https://docs.victoriametrics.com/#how-to-import-data-in-native-format). See [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/2423). BUGFIX: [Graphite Render API](https://docs.victoriametrics.com/#graphite-render-api-usage): properly calculate [hitCount](https://graphite.readthedocs.io/en/latest/functions.html#graphite.render.functions.hitcount) function. Previously it could return empty results if there were no original samples in some parts of the selected time range. BUGFIX: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): allow overriding built-in function names inside [WITH templates](https://play.victoriametrics.com/promql/expand-with-exprs). For example, `WITH (sum(a,b) = a + b + 1) sum(x,y)` now expands into `x + y + 1`. Previously such a query would fail with `cannot use reserved name` error. See [this bugreport](https://github.com/VictoriaMetrics/metricsql/issues/5). diff --git a/lib/storage/index_db.go b/lib/storage/index_db.go index cddf658d0..53c194485 100644 --- a/lib/storage/index_db.go +++ b/lib/storage/index_db.go @@ -2252,7 +2252,8 @@ func (is *indexSearch) searchMetricIDsInternal(tfss []*TagFilters, tr TimeRange, return nil, err } if metricIDs.Len() > maxMetrics { - return nil, fmt.Errorf("the number of matching unique timeseries exceeds %d; either narrow down the search or increase -search.maxUniqueTimeseries", maxMetrics) + return nil, fmt.Errorf("the number of matching timeseries exceeds %d; either narrow down the search "+ + "or increase -search.max* command-line flag values at vmselect", maxMetrics) } } return metricIDs, nil @@ -2272,6 +2273,10 @@ func (is *indexSearch) updateMetricIDsForTagFilters(metricIDs *uint64set.Set, tf atomic.AddUint64(&is.db.globalSearchCalls, 1) m, err := is.getMetricIDsForDateAndFilters(0, tfs, maxMetrics) if err != nil { + if errors.Is(err, errFallbackToGlobalSearch) { + return fmt.Errorf("the number of matching timeseries exceeds %d; either narrow down the search "+ + "or increase -search.max* command-line flag values at vmselect", maxMetrics) + } return err } metricIDs.UnionMayOwn(m)