-
Notifications
You must be signed in to change notification settings - Fork 801
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 kafka producer usage #1436
Fix kafka producer usage #1436
Conversation
@fkuehnSAG Thanks for spotting this. It's a known problem with some health checks. #1440 fixes this problem in other way. HC is singleton now + it implements |
@sungam3r okay, you are right. This really sounds like a better solution. Thank you! :) |
To be honest after looking throught the code one more time I don't think it contains memory leak. HC was registered as instance, not as factory:
so each iteration the same instance should be used. |
Effectively we have singleton-like health check even before fix. I suggest you investigate dumps one more time more carefully. However, now |
@sungam3r i was also confused when i saw it the first time but the threads appear when calling the health check and after i swapped to my version of the fix it didn't happen anymore. Here is a Screenshot that i got from the gcdump: and here a comparison of the spawned threads: There is no other place in the whole application where we are using a Producer<String, String>. So it is 100 % related to the health check. But thank you for publishing the fix! i will test it soon 👍 |
It can be so if you (or someone else) plug in this check in your app manually, i.e. without use of
I used |
@sungam3r we built a HealthChecksBuilderExtensions class like this:
So i think this should not be the issue |
It really should since factory method from |
Check out |
@sungam3r Oh yeah, i misunderstood before. You are absolutely right, this is the actual cause of the issue. I just tested it with KafkaHealthCheckBuilderExtensions and it works perfectly fine. Not sure why we implemented a own HealthCheckBuilderExtensions class with this error to be honest :/ But anyway, thank you really much and sorry for the effort ^^ |
This pull request is fixing the usage of the producer for the kafka health check. Without this "using" the producer will create threads that never get deleted anymore every time the health check is executed. I suppose this is due to the fact that according to a gcdump that i created there were 2 producer<String, String> instances (which are only used by the health check).
It should be possible to reproduce this issue by creating a project with the health check, observing the number of threads for this process (e. g.: in the task manager) and calling the health check multiple times.