KAFKA-9306: The consumer must close KafkaConsumerMetrics - #7839
Conversation
soondenana
left a comment
There was a problem hiding this comment.
Thanks Colin for finding this. Left one comment.
srpanwar-confluent
left a comment
There was a problem hiding this comment.
Signing off from testing side of things. Verified that this change fixes the issue.
|
LGTM. Thanks @cmccabe for the fix! |
|
I pared this back to a more minimalistic fix for now, so that we can get something that can address the memory leak we spotted in 2.4. This will be easy to backport. I think we should do a better fix later which makes |
|
Seems the main problem here is the lambda inside |
|
I think I see what's going on. Both KafkaMbean mbean = removeAttribute(metric, mBeanName);
if (mbean != null) {
if (mbean.metrics.isEmpty()) {
unregister(mbean);
mbeans.remove(mBeanName);
} else
reregister(mbean);
}The This bug seems to be the result of a lot of general sloppiness in the metrics library and the jmx reporter. We should probably file a JIRA to revisit these apis to make it harder for us to make this kind of mistake. We can improve testing as well probably to check for dangling mbeans. |
|
@hachikuji : great analysis. I'm thinking we get this current PR in for future dot releases, and apply #7851 to trunk. Can I get an LGTM? |
hachikuji
left a comment
There was a problem hiding this comment.
I'm happy with the current patch. Can you add a test case? I think it would be straightforward to add an assertion to one of the test cases in KafkaConsumerTest which verifies that all mbeans have been unregistered.
|
added a test |
hachikuji
left a comment
There was a problem hiding this comment.
LGTM. Thanks for the fix.
Reviewers: Vikas Singh <vikas@confluent.io>, Jason Gustafson <jason@confluent.io>, Shailesh Panwar <spanwar@confluent.io> (cherry picked from commit 7e36865)
|
Backported to 2.4 in case we do a dot release on that branch. |
Reviewers: Vikas Singh <vikas@confluent.io>, Jason Gustafson <jason@confluent.io>, Shailesh Panwar <spanwar@confluent.io> (cherry picked from commit 7e36865)
No description provided.