Skip to content
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

Update in_kafka_group.rb to fix the memory leak. #507

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/fluent/plugin/in_kafka_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ def setup_consumer

def reconnect_consumer
log.warn "Stopping Consumer"
# Following line is causing a memory leak, in scenario, where kafka is not reachable and disable_retry_limit is true.
consumer = @consumer
@consumer = nil
if consumer
Expand All @@ -254,6 +255,9 @@ def reconnect_consumer
log.error "unexpected error during re-starting consumer object access", :error => e.to_s
log.error_backtrace
if @retry_count <= @retry_limit or disable_retry_limit
# Adding the following line to ensure, consumer object is cleaned before recursively calling reconnect_consumer.
# This ensures no memory leak.
consumer = nil
reconnect_consumer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably just calling retry here is better than resetting consumer and calling reconnect_consumer recursively.

end
end
Expand Down