-
Notifications
You must be signed in to change notification settings - Fork 23
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
Size limit bytes #43
Merged
Merged
Size limit bytes #43
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
Closed
mashhurs
reviewed
Aug 28, 2024
mashhurs
reviewed
Aug 28, 2024
Co-authored-by: Mashhur <99575341+mashhurs@users.noreply.github.com>
mashhurs
approved these changes
Aug 28, 2024
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.
This was referenced Aug 30, 2024
This was referenced Mar 6, 2025
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.
Release notes
Add
decode_size_limit_bytes
option to limit the maximum size of JSON document that can be parsedWhat does this PR do?
Leverages the second parameter of
BufferTokenizerExt
https://github.com/elastic/logstash/blob/6e93b30c7fd809e148c1c1472954c1c56fbcd994/logstash-core/src/main/java/org/logstash/common/BufferedTokenizerExt.java#L58 to thrown an IllegalStateException when the size of the line to parse is bigger thandecode_size_limit_bytes
Why is it important/What is the impact to the user?
As a user of
json_lines
codec I don't want that a single big line could generate an OOM error and kill the Logstash process.Checklist
[ ] I have made corresponding change to the default configuration files (and/or docker env variables)[ ] I have added tests that prove my fix is effective or that my feature worksAuthor's Checklist
How to test this PR locally
Used 1 line big json file (~1GB), limited the Java heap to 512Mb, and processed with a file input plugin. It goes in OOM
Generate one big json file
Use the script to generate it:
Configure Logstash
In
config/jvm.options
setand execute the pipeline
Configure this patch PR, in
Gemfile
replace
"logstash-codec-json_lines"
with
and execute
Run with:
cat /path/to/big_single_line.json | bin/logstash -f /path/to/test_oom_pipeline.conf
Attention that testing with
logstash-input-file
we occur in a similar problem, but that happens before the codec is invoked logstash-plugins/logstash-input-file#210Related issues
Logs
The console output with this PR
The error repeats but doesn't kill the pipeline.
Without this PR the Logstash process is killed by OOM like in: