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

receiver/kafka: error handling fixes #413

Merged
merged 3 commits into from
Jul 7, 2021
Merged

Conversation

bom-d-van
Copy link
Member

Two changes for issue #412.

  1. receiver/kafka: fix kafka connection leaks when it fails to consume partition

    Clients and consumers are not closed when consumer.ConsumePartition failed, which creates a resource leaks. If the error is sticky due to bad offset saved in state file, the receiver would keep creating new consumer connections and not closing them.

    This commit fixes the issue, by making sure the connections and consumers are closed if there is errors when trying to consume a partition.

    At the same time, if an sarama.ErrOffsetOutOfRange error is returned, it would just falls back to oldest offset, instead of keep retrying.

  2. moves time.NewTicker out of for loop

…rtition

Clients and consumers are not closed when consumer.ConsumePartition failed, which
creates a resource leaks. If the error is sticky due to bad offset saved in state
file, the receiver would keep creating new consumer connections and not closing them.

This commit fixes the issue, by making sure the connections and consumers are
closed if there is errors when trying to consume a partition.

At the same time, if an sarama.ErrOffsetOutOfRange error is returned, it would just
falls back to oldest offset, instead of keep retrying.
It is not necessary to create new ticker in every loop.
@bom-d-van bom-d-van merged commit 7010d1c into master Jul 7, 2021
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.

2 participants