Skip to content
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

Merged

Conversation

danhermann
Copy link
Contributor

@danhermann danhermann commented Jul 6, 2018

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.

@elasticsearch-bot elasticsearch-bot self-assigned this Jul 6, 2018
pending = Queue.new
events.each {|e| pending << [e, 0]}
if @format == "json_batch"
pending << [events, 0, true]
Copy link
Member

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?

@jsvd jsvd assigned jsvd and unassigned elasticsearch-bot Jul 6, 2018

# Compress the body and add appropriate header
if @http_compression == true
if @http_compression == true && !@is_batch
Copy link
Member

@jsvd jsvd Jul 6, 2018

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.
Copy link
Member

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).

Copy link
Member

@jsvd jsvd left a 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

@danhermann danhermann merged commit 06fd440 into logstash-plugins:master Jul 6, 2018
@danhermann danhermann deleted the 86_high_cpu_on_retries branch July 6, 2018 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants