-
Notifications
You must be signed in to change notification settings - Fork 12
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
Bugfix for uninterrupted receive loop #18
Bugfix for uninterrupted receive loop #18
Conversation
Adjust implementation of util/zeromq.rb to zeromq output. logstash-plugins/logstash-output-zeromq#13
Replace the uninterrupted receive loop (non-blocking) with a blocking loop with a default timeout of 1000ms.
Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run; then say 'jenkins, test it'. |
@@ -20,8 +20,8 @@ def setup(socket, address) | |||
@logger.info("0mq: #{server? ? 'connected' : 'bound'}", :address => address) | |||
end | |||
|
|||
def error_check(rc, doing) | |||
unless ZMQ::Util.resultcode_ok?(rc) | |||
def error_check(rc, doing, eagain_not_error = false) |
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.
Because function signature of error_check is changed and util/zeromq.rb is present in zeromq input and output plugin, this PR has a dependecy to logstash-plugins/logstash-output-zeromq/pull/13.
Could please someone give me some feedback? |
This would be really good if any maintainer could have a look on this. |
OK, had a look. The patch looks straight forward. I do need to run some tests so it will take a few days to close this. Thanks! |
I'm really interested in this fix. I'm having two zeromq inputs taking up half of the server cpu capacity. So if there is any thing I can do to help, feel free to delegate. |
@erikthorselius Have you tried this PR in your setup? Did it solve your problem? |
Looks good! I'm new to logstash but here is how I tested. My server is running coreos so I built a docker container. My dockerfile:
and on my server
Same process is now down to 1.8% instead of 200%
|
# | ||
# defaults to: `sockopt => ["ZMQ::RCVTIMEO", "1000"]`, which has the effect of "interrupting" | ||
# the recv operation at least once every second to allow for properly shutdown handling. | ||
config :sockopt, :validate => :hash, :default => [ "ZMQ::RCVTIMEO", "1000" ] |
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.
This should probably be :default => { "ZMQ::RCVTIMEO" => "1000" }
right?
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 agree, it should be a hash. I just followed the existing example, which provides an array with an even count of elements, which gets converted to a hash in https://github.com/elastic/logstash/blob/master/logstash-core/lib/logstash/config/mixin.rb#L381 (lines 381 - 398). I update the PR, including the existing comment/example.
Given @erikthorselius's success report, I'm OK merging this. Code LGTM except for my one comment about the hash default value (should use hash syntax, not array). @breml Can you address my comment? I'm happy to merge once done. :) |
@erikthorselius Please see my comment regarding @jordansissel this is quiet an annoying issue. I suggest to either really duplicate the code by moving |
Maybe a stupid question but how do I update that? Would it work to uninstall logstash-output-zeromq? |
@erikthorselius Uninstalling the logstash-output-zeromq plugin may work. If it doesn't, I recommend to rename |
I'm so sorry forgetting this. I blame work. I have tested this again and it works perfect! The cpu goes from 200% to 0.3 % and i still receive logs. |
i'm going to start working on refactoring common zeromq code to a new gem, this should ease maintenance of logstash zeromq plugins. i'll update soon. |
@breml Thanks for this. Could you please bump the version in the gemspec and add a changelog? I can merge this, then and publish a new version |
@suyograo Sure I would like to update gemspec and changelog, but this change should not be merged without either logstash-plugins/logstash-output-zeromq#13 or the refactoring mentioned by @avishai-ish-shalom, because of https://github.com/logstash-plugins/logstash-input-zeromq/pull/18/files#r47354652. |
This PR is on hold until logstash-mixin-zeromq is integrated. cc @breml |
Replace the uninterrupted receive loop (non-blocking) with
a blocking loop with a default timeout of 1000ms.
Restores compatibility with zeromq output plugin for util/zeromq.rb as well, if logstash-plugins/logstash-output-zeromq#13 is merged.
Closes #17
May also be related to #5