From ec75d9097dda27c9d1164a386d0772f921616d75 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 5 Jul 2023 21:13:32 -0700 Subject: [PATCH] app/vmselect/netstorage: follow-up after 11ac551d5244eacbec751e5d3c63a38e36942b84 - Clarify the scope of the fix at docs/CHANGELOG.md - Handle the case when -search.maxSamplesPerSeries limit is exceeded in the same way as the -search.maxSamplesPerQuery limit. Updates https://github.com/VictoriaMetrics/VictoriaMetrics/pull/4472 --- app/vmselect/netstorage/netstorage.go | 14 +++++++++----- docs/CHANGELOG.md | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/vmselect/netstorage/netstorage.go b/app/vmselect/netstorage/netstorage.go index 71cc4dce6..1a90d74e0 100644 --- a/app/vmselect/netstorage/netstorage.go +++ b/app/vmselect/netstorage/netstorage.go @@ -485,8 +485,10 @@ func (pts *packedTimeseries) unpackTo(dst []*sortBlock, tbfs []*tmpBlocksFile, t samples += len(upw.sb.Timestamps) if *maxSamplesPerSeries > 0 && samples > *maxSamplesPerSeries { putSortBlock(upw.sb) - err = fmt.Errorf("cannot process more than %d samples per series; either increase -search.maxSamplesPerSeries "+ - "or reduce time range for the query", *maxSamplesPerSeries) + err = &limitExceededErr{ + err: fmt.Errorf("cannot process more than %d samples per series; either increase -search.maxSamplesPerSeries "+ + "or reduce time range for the query", *maxSamplesPerSeries), + } break } dst = append(dst, upw.sb) @@ -1532,9 +1534,11 @@ func ProcessSearchQuery(qt *querytracer.Tracer, denyPartialResponse bool, sq *st blocksRead.Add(workerID, 1) n := samples.Add(workerID, uint64(mb.Block.RowsCount())) if *maxSamplesPerQuery > 0 && n > maxSamplesPerWorker && samples.GetTotal() > uint64(*maxSamplesPerQuery) { - return &limitExceededErr{err: fmt.Errorf("cannot select more than -search.maxSamplesPerQuery=%d samples; possible solutions: "+ - "to increase the -search.maxSamplesPerQuery; to reduce time range for the query; "+ - "to use more specific label filters in order to select lower number of series", *maxSamplesPerQuery)} + return &limitExceededErr{ + err: fmt.Errorf("cannot select more than -search.maxSamplesPerQuery=%d samples; possible solutions: "+ + "to increase the -search.maxSamplesPerQuery; to reduce time range for the query; "+ + "to use more specific label filters in order to select lower number of series", *maxSamplesPerQuery), + } } if err := tbfw.RegisterAndWriteBlock(mb, workerID); err != nil { return fmt.Errorf("cannot write MetricBlock to temporary blocks file: %w", err) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 0a9847a61..1a5f2d353 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -36,7 +36,7 @@ The following tip changes can be tested by building VictoriaMetrics components f Remove redundant limit from [Prometheus api/v1/series](https://docs.victoriametrics.com/Single-server-VictoriaMetrics.html#prometheus-querying-api-usage). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4339). * BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): fix panic on vmagent shutdown which could lead to loosing aggregation results which were not flushed to remote yet. See [this](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/4407) for details. * BUGFIX: [vmbackupmanager](https://docs.victoriametrics.com/vmbackupmanager.html): fix an issue with `vmbackupmanager` not being able to restore data from a backup stored in GCS. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4420) for details. -* BUGFIX: properly return the error to user when `-search.maxSamplesPerQuery` limit is exceeded. Before, user could have received a partial response instead. +* BUGFIX: [VictoriaMetrics cluster](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html): properly return error from [/api/v1/query](https://docs.victoriametrics.com/keyConcepts.html#instant-query) and [/api/v1/query_range](https://docs.victoriametrics.com/keyConcepts.html#range-query) at `vmselect` when the `-search.maxSamplesPerQuery` or `-search.maxSamplesPerSeries` [limit](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#resource-usage-limits) is exceeded. Previously incomplete response could be returned without the error if `vmselect` runs with `-replicationFactor` greater than 1. See [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/4472). ## [v1.91.2](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.91.2)