fix(cli): resolve infinite loop and output bugs in log merging#743
Merged
doringeman merged 2 commits intodocker:mainfrom Mar 9, 2026
Merged
fix(cli): resolve infinite loop and output bugs in log merging#743doringeman merged 2 commits intodocker:mainfrom
doringeman merged 2 commits intodocker:mainfrom
Conversation
printMergedLog would infinite-loop when two log files contained lines with identical timestamps, since neither inner loop condition advanced. Signed-off-by: Dorin Geman <dorin.geman@docker.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request effectively resolves a critical infinite loop bug in the log merging logic that occurred when log entries had identical timestamps. The fix is correct and also includes a regression test to prevent this issue in the future. Additionally, the changes address an output bug where the last log line could be dropped, and refactors the code to improve testability by using io.Writer and replacing println with fmt.Fprintln. The introduction of new tests significantly improves the robustness of the log merging functionality. I've noted a minor improvement in the new test file to handle potential errors during test setup.
Signed-off-by: Dorin Geman <dorin.geman@docker.com>
ilopezluna
approved these changes
Mar 9, 2026
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.
When
timestamp1 == timestamp2, neitherBeforecheck is true, so neither inner loop executes. The outer loop condition is still true, creating an infinite loop. This happens frequently in practice since the service and engine logs often emit lines at the same time.Without the second commit, you can easily reproduce this.