lib/logstorage: fix time ordering in running_stats and total_stats#1591
Open
func25 wants to merge 3 commits into
Open
lib/logstorage: fix time ordering in running_stats and total_stats#1591func25 wants to merge 3 commits into
func25 wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
func25
force-pushed
the
fix-running-stats-time
branch
from
July 10, 2026 08:22
6a26bae to
a8c984e
Compare
Member
There was a problem hiding this comment.
If I understand it correctly, this PR contains both optimizations and the bug fix, I propose to only fix the bug to simplify the changes. See this git diff that also fixes the bug, but looks simplier:
diff --git a/lib/logstorage/pipe_running_stats.go b/lib/logstorage/pipe_running_stats.go
index 76c9a2009..9e6fa931c 100644
--- a/lib/logstorage/pipe_running_stats.go
+++ b/lib/logstorage/pipe_running_stats.go
@@ -271,7 +271,12 @@ func (psp *pipeRunningStatsProcessor) flush() error {
for _, key := range keys {
rows := m[key]
sort.Slice(rows, func(i, j int) bool {
- return rows[i].timestamp < rows[j].timestamp
+ v1, ok1 := TryParseTimestampRFC3339Nano(rows[i].timestamp)
+ v2, ok2 := TryParseTimestampRFC3339Nano(rows[j].timestamp)
+ if !ok1 || !ok2 {
+ return rows[i].timestamp < rows[j].timestamp
+ }
+ return v1 < v2
})
if needStop(psp.stopCh) {
Member
Author
There was a problem hiding this comment.
Yeah it is simpler, but I think the above would fix only the symptom and require the better fix anyway. Also this follows the timestamp-handling approach used by the sort pipe, so we could see it as keeping timestamp handling consistent across pipes rather than as a separate optimization.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
running_statsandtotal_statsprocess rows in the wrong order as_timevalues were compared as text instead of timestamps.Fixes them to use the actual timestamp value when available, and to parse string
_timevalues before falling back to text ordering (backward compat). Also keep_timeinupdateNeededFieldsso ordering still works, this is documented.Fixes #1581