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
backport a JRuby 9.1.16.0 stdlib resolv.rb patch on earlier versions #45
backport a JRuby 9.1.16.0 stdlib resolv.rb patch on earlier versions #45
Conversation
lib/logstash/filters/resolv_patch.rb
Outdated
version = JRUBY_VERSION.split(".").map(&:to_i) | ||
|
||
if version[0] == 9 && version[1] == 1 && version[2] < 16 | ||
class Resolv |
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.
It'd be cool to document where this code comes from: https://github.com/jruby/jruby/blob/9.1.16.0/lib/ruby/stdlib/resolv.rb#L775
lib/logstash/filters/resolv_patch.rb
Outdated
|
||
version = JRUBY_VERSION.split(".").map(&:to_i) | ||
|
||
if version[0] == 9 && version[1] == 1 && version[2] < 16 |
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.
ruby's most common way to compare versions is through Gem::Version, we could rewrite:
version = JRUBY_VERSION.split(".").map(&:to_i)
if version[0] == 9 && version[1] == 1 && version[2] < 16
as:
if Gem::Version.new("9.1.16.0") > Gem::Version.new(JRUBY_VERSION)
or
RESOLV_PATCH_CONSTRAINT = Gem::Requirement.new("< 9.1.16.0")
if RESOLV_PATCH_CONSTRAINT.satisfied_by?(Gem::Version.new(JRUBY_VERSION))
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.
Does this work on JRuby 1.7 as well? Have you checked if there has been much changes to resolv.rb since then?
I'm just wondering if the exact same patch will work for Logstash 5.x / JRuby 1.7.
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 stress tested the 1.7.25 and 1.7.27 (the 2 JRuby vesions used across the LS 5 versions) resolver and they are not affected by this bug. Only 9k need patching and 9.1.13.0 is the first 9k version we used.
@@ -1,3 +1,6 @@ | |||
## 3.0.11 | |||
- Fixed JRuby resolver bug for versions prior to 9.1.16.0 [#45](https://github.com/logstash-plugins/logstash-filter-dns/pull/45) |
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.
for JRuby versions prior..
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.
? "Fixed JRuby ... for versions prior" ... not sure how this is confusing?
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.
you're right, I was nitpicking
I agree with both of @jsvd's requests for changes. If they get added and you confirm that the patch works on 5.x as well, this LGTM |
@jsvd thanks for the suggestions, pushed modification. LMK. |
@webmat I am recopying my code comment about this:
|
This means we should also constrain the application of the patch to something like |
@jsvd ah yes - totally - my previous check was indeed valid for hard checking on version 9 but my refactor using Gem omits that will change. |
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
…JRuby version code source and use Gem for version comparison constrain version in 9k and more comments
logstash-filter-dns v 3.0.11 published. |
Fixes #40
The installed JRuby version 9.1.13.0 has a bug in the stdlib resolv.rb that has been fixed in 9.1.16.0
This bug result in the resolver hanging after 64k unique IP resolutions.
This patch is also submitted in core elastic/logstash/pull/9750. I do not see a problem having the patch in the 2 places, this one here will apply on any LS version and eventually if a patched LS version is used it wont cause problem since the patching is guarded using a version check.
I testing this locally, see #40.