[20.10 backport] daemon/logger: read the length header correctly #43165
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.
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)