-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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 for not reusable http client leading to connection leaks in Jolokia module #11014
Fix for not reusable http client leading to connection leaks in Jolokia module #11014
Conversation
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
d9df886
to
b0702e1
Compare
Hi @mirkochip, Thanks for opening this PR and raising awareness about this issue. It actually looks like a potential problem that could affect all http-based metricbeat modules. There is already a So, I don't see the need of adding an specific timeout option for the Jolokia module, but we could:
Would you like to do these changes here? If not I am happy to do them too in a new PR. Thanks! |
Something that is probably doing this problem worse in the Jolokia module than in other modules is that it creates a new client for each request, it should reuse the client. |
b0702e1
to
6cc267e
Compare
Hello @jsoriano, many thanks for your reply and interest in my PR! You pointed me in the right direction: with my latest push Jolokia should now take advantage of the already existing clients, instead of instantiate always a new one! |
6cc267e
to
af981c6
Compare
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.
Thanks for doing these changes! Could you edit the title and description of the pull request to match current changes?
af981c6
to
c0070b6
Compare
jenkins, test this |
@mirkochip thanks for the changes, this LGTM, could you please add a changelog entry in |
c0070b6
to
6ee1332
Compare
Sure, done! |
@mirkochip btw, I started a PR to set default timeouts, find it in #11032 in case you want to give any feedback. Thanks! |
It sounds super, I'll have a look at it! Thanks. |
@mirkochip sorry, one last thing, could you move the changelog entry from the breaking changes section to the bugfixes section for metricbeat? thanks! |
5395e68
to
89ade1c
Compare
Done :) |
jenkins, test this |
Co-Authored-By: mirkochip <[email protected]>
89ade1c
to
bc7d46a
Compare
jenkins, test this |
…kia module (elastic#11014) Jolokia module was creating a new HTTP helper for each request, what was leading to leaks under some scenarios. Make it reuse connections. (cherry picked from commit 288a76c)
…kia module (#11014) (#11087) Jolokia module was creating a new HTTP helper for each request, what was leading to leaks under some scenarios. Make it reuse connections. (cherry picked from commit 288a76c) Co-Authored-By: Carmelo Mirko Musumeci <[email protected]>
In a host where I have three Wildfly 9 running instances, I installed metricbeat along with Jolokia module in order to keep track of JVM heap usage, etc.
I'm able to collect regularly all the needed metrics, but after a while that Metricbeat/Jolokia is running, it reaches the limit of maximum file opened in the system, and then it breaks saying:
write error: failed to open new file: open /var/log/metricbeat/metricbeat: too many open files
.Checking the status of connections by metricbeat PID:
netstat --all --program | grep '<PID>'
, I get tons of entries like the following ones:Metricbeat will definitely break after a while, when the number of the above entries is equal to the maximum number of open file descriptors parameter set for the user running the process (
ulimit
).Thanks also to @jsoriano, we found out that the Jolokia module creates a new client for each request, instead of reusing the already available clients, leading to an unavoidable connections leak.
This PR introduces a fix for it.