diff --git a/docs/VictoriaLogs/CHANGELOG.md b/docs/VictoriaLogs/CHANGELOG.md index 2f2617ee8..3a4846b2e 100644 --- a/docs/VictoriaLogs/CHANGELOG.md +++ b/docs/VictoriaLogs/CHANGELOG.md @@ -19,6 +19,8 @@ according to [these docs](https://docs.victoriametrics.com/VictoriaLogs/QuickSta ## tip +* BUGFIX: properly take into account `offset` [`sort` pipe](https://docs.victoriametrics.com/victorialogs/logsql/#sort-pipe) when it already has `limit`. For example, `_time:5m | sort by (foo) offset 20 limit 10`. + ## [v0.7.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v0.7.0-victorialogs) Released at 2024-05-15 diff --git a/lib/logstorage/pipe_topk.go b/lib/logstorage/pipe_topk.go index 42b18df6a..d18e3039b 100644 --- a/lib/logstorage/pipe_topk.go +++ b/lib/logstorage/pipe_topk.go @@ -263,7 +263,7 @@ func (shard *pipeTopkProcessorShard) addRow(byColumns []string, otherColumns []F // Slow path - add r to shard.rows. r = r.clone() shard.stateSizeBudget -= r.sizeBytes() - if uint64(len(rows)) < shard.ps.limit { + if uint64(len(rows)) < shard.ps.offset+shard.ps.limit { heap.Push(shard, r) shard.stateSizeBudget -= int(unsafe.Sizeof(r)) } else {