-
Notifications
You must be signed in to change notification settings - Fork 82
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
Fix high CPU on retries in json_batch mode #89
Fix high CPU on retries in json_batch mode #89
Conversation
lib/logstash/outputs/http.rb
Outdated
pending = Queue.new | ||
events.each {|e| pending << [e, 0]} | ||
if @format == "json_batch" | ||
pending << [events, 0, true] |
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.
By setting a @is_batch
variable (w/ a is_batch
accessor) to true or false based on the :format
parameter during the register
method we can avoid passing it around in multiple places, greatly simplifying the code. wdyt?
lib/logstash/outputs/http.rb
Outdated
|
||
# Compress the body and add appropriate header | ||
if @http_compression == true | ||
if @http_compression == true && !@is_batch |
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.
I know this is to keep current behaviour but the current behaviour is a bug so we can fix it here too, also replacing #88 (just by removing this change now that the code path is shared.
CHANGELOG.md
Outdated
@@ -1,3 +1,6 @@ | |||
## 5.2.2 | |||
- Fix high CPU usage on retries in json_batch mode. |
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.
sorry, one last detail, can you add the this pr's reference to the changelog entry? we have guidelines for editing the changelog here (these guidelines are somewhat recent we need to make them easier to find).
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! squash (you can use the GH squash button) and 🚢 it
The high CPU on retries occurred because there was a separate code path for
json_batch
mode where retries were attempted in a hot loop. This PR unifies those code paths so that the proper back-off behavior is applied to retries in all modes.Fixes #86, #88.