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

fix: Kafka client resource leak #469

Merged
merged 1 commit into from
Feb 21, 2025

Conversation

jalaziz
Copy link
Contributor

@jalaziz jalaziz commented Feb 16, 2025

Sarama Kafka clients leak several resources (goroutines, metrics, connections) if not closed properly. A client is created and managed within the topic manager and therefore a topic manager will leak resources if not properly closed.

Topic Managers are created in two places:

  1. When calling prepareTopics while instantiating a new processor.
  2. Within processor.Run.

The first of these is correctly closed, but the latter was not. Closing the second instance should ensure underlying Sarama resources are appropriate cleaned up when a processor stops.

Sarama Kafka clients leak several resources (goroutines, metrics,
connections) if not closed properly. A client is created and managed
within the topic manager and therefore a topic manager will leak
resources if not properly closed.

Topic Managers are created in two places:

1. When calling `prepareTopics` while instantiating a new processor.
2. Within `processor.Run`.

The first of these is correctly closed, but the latter was not. Closing
the second instance should ensure underlying Sarama resources are
appropriate cleaned up when a processor stops.
Copy link
Contributor

@frairon frairon left a comment

Choose a reason for hiding this comment

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

awesome, thanks!

Copy link
Contributor

@mmreza79 mmreza79 left a comment

Choose a reason for hiding this comment

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

nice :)

@jalaziz
Copy link
Contributor Author

jalaziz commented Feb 21, 2025

Happy to help! If there's anything else I can do to help get this over the line and released, please let me know 🙏🏼. It was actively affecting some of our workloads, so we'd love to upgrade to a patched version.

@norbertklawikowski norbertklawikowski merged commit 5c19cef into lovoo:master Feb 21, 2025
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants