app/vlselect/logsql: call Query.Optimize() on the cloned query in order to replace * filter with filterNoop inside getLastNQueryResults()

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6785
This commit is contained in:
Aliaksandr Valialkin 2024-09-18 18:24:14 +02:00
parent b82e2cabc5
commit e86891b010
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
2 changed files with 5 additions and 0 deletions

View file

@ -864,6 +864,9 @@ func getLastNQueryResults(ctx context.Context, tenantIDs []logstorage.TenantID,
for {
q = qOrig.Clone()
q.AddTimeFilter(start, end)
// q.Optimize() call is needed for converting '*' into filterNoop.
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6785#issuecomment-2358547733
q.Optimize()
rows, err := getQueryResultsWithLimit(ctx, tenantIDs, q, limitUpper)
if err != nil {
return nil, err

View file

@ -15,6 +15,8 @@ according to [these docs](https://docs.victoriametrics.com/victorialogs/quicksta
## tip
* BUGFIX: properly return logs without [`_msg`](https://docs.victoriametrics.com/victorialogs/keyconcepts/#message-field) field when `*` query is passed to [`/select/logsql/query` endpoint](https://docs.victoriametrics.com/victorialogs/querying/#querying-logs) together with positive `limit` arg. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6785). Thanks to @jiekun for itentifying the root cause of the issue.
## [v0.29.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v0.29.0-victorialogs)
Released at 2024-09-08