New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[20.10 backport] daemon/logger: read the length header correctly #43165
Merged
Conversation
This file contains 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
Before this change, if Decode() couldn't read a log record fully, the subsequent invocation of Decode() would read the record's non-header part as a header and cause a huge heap allocation. This change prevents such a case by having the intermediate buffer in the decoder struct. Fixes moby#42125. Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com> (cherry picked from commit 48d387a) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com> (cherry picked from commit f2e458e) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
followLogs() is getting really long (170+ lines) and complex. The function has multiple inner functions that mutate its variables. To refactor the function, this change introduces follow{} struct. The inner functions are now defined as ordinal methods, which are accessible from tests. Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com> (cherry picked from commit 7a10f5a) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com> (cherry picked from commit c91e09b) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
thaJeztah
added
area/logging
status/2-code-review
impact/changelog
kind/bugfix
PR's that fix bugs
labels
Jan 20, 2022
@cpuguy83 @samuelkarp ptal |
samuelkarp
approved these changes
Jan 27, 2022
cpuguy83
approved these changes
Jan 27, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
3 tasks
I can't verify this issuse by runing
I can reproduce it by running (thanks to @aeriksson ) terminal 1
terminal 2
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
fixes #42125
Backport of:
Before this change, if Decode() couldn't read a log record fully,
the subsequent invocation of Decode() would read the record's non-header part
as a header and cause a huge heap allocation.
This change prevents such a case by having the intermediate buffer in
the decoder struct.
Fixes #42125.
- What I did
Changing decoder struct to fix #42125.
- How I did it
Changing decoder struct to keep read-but-unused bytes.
- How to verify it
Run
docker logs -f $(docker run --rm -d --log-driver local alpine cat /dev/urandom) > /dev/null
. It kills dockerd after a few minutes before the change.- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)
(from https://www.zooborns.com/zooborns/2021/05/two-very-different-babies-emerge-at-woodland-park-zoo.html)