Skip to content

lib/logstorage: fix topk wrong ordering with mixed _time sources#1361

Open
cuongleqq wants to merge 4 commits into
VictoriaMetrics:masterfrom
cuongleqq:fix-topk-mixed-time-compare
Open

lib/logstorage: fix topk wrong ordering with mixed _time sources#1361
cuongleqq wants to merge 4 commits into
VictoriaMetrics:masterfrom
cuongleqq:fix-topk-mixed-time-compare

Conversation

@cuongleqq
Copy link
Copy Markdown
Contributor

sort by (_time) limit N could return logs out of order when results contained a mix of rows with original _time and rows with _time overwritten by pipes like unpack_json.

The root cause was a bug in topkLess (I think it's copy-paste problem).

I fixed the bug and added a test for topkLess

Fixes #1360

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@func25 func25 added the bug Something isn't working label Apr 28, 2026
Comment thread lib/logstorage/pipe_sort_topk_test.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sort pipe: sort by (_time) limit can misorder unpacked JSON time values

3 participants