From 7916bb2789e79696c90ed4a0fd281a2e021145ee Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Sat, 25 May 2024 20:45:11 +0200 Subject: [PATCH] wip --- docs/VictoriaLogs/CHANGELOG.md | 1 + lib/logstorage/pipe_stats.go | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/VictoriaLogs/CHANGELOG.md b/docs/VictoriaLogs/CHANGELOG.md index 1ff5f611d..963bafeaa 100644 --- a/docs/VictoriaLogs/CHANGELOG.md +++ b/docs/VictoriaLogs/CHANGELOG.md @@ -25,6 +25,7 @@ according to [these docs](https://docs.victoriametrics.com/victorialogs/quicksta * FEATURE: improve performance for [`format`](https://docs.victoriametrics.com/victorialogs/logsql/#format-pipe) and [`extract`](https://docs.victoriametrics.com/victorialogs/logsql/#extract-pipe) pipes. * FEATURE: improve performance for [`/select/logsql/field_names` HTTP API](https://docs.victoriametrics.com/victorialogs/querying/#querying-field-names). +* BUGFIX: prevent from panic in [`sort` pipe](https://docs.victoriametrics.com/victorialogs/logsql/#sort-pipe) when VictoriaLogs runs on a system with one CPU core. * BUGFIX: do not return referenced fields if they weren't present in the original logs. For example, `_time:5m | format if (non_existing_field:"") "abc"` could return empty `non_exiting_field`, while it shuldn't be returned because it is missing in the original logs. * BUGFIX: properly initialize values for [`in(...)` filter](https://docs.victoriametrics.com/victorialogs/logsql/#exact-filter) inside [`filter` pipe](https://docs.victoriametrics.com/victorialogs/logsql/#filter-pipe) if the `in(...)` contains other [filters](https://docs.victoriametrics.com/victorialogs/logsql/#filters). For example, `_time:5m | filter ip:in(user_type:admin | fields ip)` now works correctly. diff --git a/lib/logstorage/pipe_stats.go b/lib/logstorage/pipe_stats.go index 9e2a13102..77504dec2 100644 --- a/lib/logstorage/pipe_stats.go +++ b/lib/logstorage/pipe_stats.go @@ -436,8 +436,9 @@ func (psp *pipeStatsProcessor) flush() error { // Merge states across shards shards := psp.shards - shards[0].init() - m := shards[0].m + shardMain := &shards[0] + shardMain.init() + m := shardMain.m shards = shards[1:] for i := range shards { shard := &shards[i] @@ -463,8 +464,8 @@ func (psp *pipeStatsProcessor) flush() error { byFields := psp.ps.byFields if len(byFields) == 0 && len(m) == 0 { // Special case - zero matching rows. - _ = shards[0].getPipeStatsGroup(nil) - m = shards[0].m + _ = shardMain.getPipeStatsGroup(nil) + m = shardMain.m } rcs := make([]resultColumn, 0, len(byFields)+len(psp.ps.funcs))