mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 20:37:12 +01:00
app/vmselect/netstorage: properly process -search.maxSamplesPerQuery
limit (#4472)
Properly return the error to user when `-search.maxSamplesPerQuery` limit is exceeded. Before, user could have received a partial response instead. Signed-off-by: hagen1778 <roman@victoriametrics.com>
This commit is contained in:
parent
bf4120a3d9
commit
11ac551d52
@ -1498,6 +1498,16 @@ func SearchMetricNames(qt *querytracer.Tracer, denyPartialResponse bool, sq *sto
|
|||||||
return metricNames, isPartial, nil
|
return metricNames, isPartial, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// limitExceededErr error generated by vmselect
|
||||||
|
// on checking complexity limits during processing responses
|
||||||
|
// from storage nodes.
|
||||||
|
type limitExceededErr struct {
|
||||||
|
err error
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error satisfies error interface
|
||||||
|
func (e limitExceededErr) Error() string { return e.err.Error() }
|
||||||
|
|
||||||
// ProcessSearchQuery performs sq until the given deadline.
|
// ProcessSearchQuery performs sq until the given deadline.
|
||||||
//
|
//
|
||||||
// Results.RunParallel or Results.Cancel must be called on the returned Results.
|
// Results.RunParallel or Results.Cancel must be called on the returned Results.
|
||||||
@ -1522,9 +1532,9 @@ func ProcessSearchQuery(qt *querytracer.Tracer, denyPartialResponse bool, sq *st
|
|||||||
blocksRead.Add(workerID, 1)
|
blocksRead.Add(workerID, 1)
|
||||||
n := samples.Add(workerID, uint64(mb.Block.RowsCount()))
|
n := samples.Add(workerID, uint64(mb.Block.RowsCount()))
|
||||||
if *maxSamplesPerQuery > 0 && n > maxSamplesPerWorker && samples.GetTotal() > uint64(*maxSamplesPerQuery) {
|
if *maxSamplesPerQuery > 0 && n > maxSamplesPerWorker && samples.GetTotal() > uint64(*maxSamplesPerQuery) {
|
||||||
return fmt.Errorf("cannot select more than -search.maxSamplesPerQuery=%d samples; possible solutions: "+
|
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 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)
|
"to use more specific label filters in order to select lower number of series", *maxSamplesPerQuery)}
|
||||||
}
|
}
|
||||||
if err := tbfw.RegisterAndWriteBlock(mb, workerID); err != nil {
|
if err := tbfw.RegisterAndWriteBlock(mb, workerID); err != nil {
|
||||||
return fmt.Errorf("cannot write MetricBlock to temporary blocks file: %w", err)
|
return fmt.Errorf("cannot write MetricBlock to temporary blocks file: %w", err)
|
||||||
@ -1718,6 +1728,13 @@ func (snr *storageNodesRequest) collectResults(partialResultsCounter *metrics.Co
|
|||||||
snr.finishQueryTracers("cancel request because of error in other vmstorage nodes")
|
snr.finishQueryTracers("cancel request because of error in other vmstorage nodes")
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
var limitErr *limitExceededErr
|
||||||
|
if errors.As(err, &limitErr) {
|
||||||
|
// Immediately return the error, since complexity limits are already exceeded,
|
||||||
|
// and we don't need to process the rest of results.
|
||||||
|
snr.finishQueryTracers("cancel request because query complexity limit was exceeded")
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
errsPartial = append(errsPartial, err)
|
errsPartial = append(errsPartial, err)
|
||||||
if snr.denyPartialResponse && len(errsPartial) >= *replicationFactor {
|
if snr.denyPartialResponse && len(errsPartial) >= *replicationFactor {
|
||||||
// Return the error to the caller if partial responses are denied
|
// Return the error to the caller if partial responses are denied
|
||||||
|
@ -36,6 +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).
|
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: [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: [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.
|
||||||
|
|
||||||
## [v1.91.2](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.91.2)
|
## [v1.91.2](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.91.2)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user