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 rdkafka consumer hanging when disconnecting #13144

Merged
merged 5 commits into from Dec 1, 2022

Conversation

GaryWilber
Copy link
Contributor

Calling consumer.close() was hanging indefinitely when the optimizedRebalance config was enabled.

The issue is the same as confluentinc/confluent-kafka-go#767

The rebalance method needs to call consumer.unassign() when closing. It was not doing this because this.consumer was being set to undefined before disconnecting.

@GaryWilber GaryWilber requested a review from a team as a code owner November 30, 2022 22:27
@github-actions github-actions bot added area: server Server related issues (routerlicious) base: main PRs targeted against main branch labels Nov 30, 2022
...this.consumerOptions.additionalOptions,
...this.sslOptions,
};

const consumer: kafkaTypes.KafkaConsumer = this.consumer =
consumer = this.consumer =
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the build is failing because it says consumer.subscribe() in line 127 below and consumer.consume() could possibly be undefined

src/rdkafkaConsumer.ts:127:4 - error TS2532: Object is possibly 'undefined'.

}

// eslint-disable-next-line prefer-const
let consumer: kafkaTypes.KafkaConsumer;
Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't reassign this later, why not make it const instead of disabling the eslint rule?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because it needs to be declared ahead of time for use by the "rebalance_cb" property in the kafka consumer constructor options.

@GaryWilber GaryWilber merged commit 8e33bf1 into microsoft:main Dec 1, 2022
@GaryWilber GaryWilber deleted the user/garywilb/consumer_hang branch December 1, 2022 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: server Server related issues (routerlicious) base: main PRs targeted against main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants