You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix: KafkaClient.closeConsumer should not block (#73)
* Fix: make `KafkaConsumer.commitSync` non-blocking
Motivation:
Currently our invocation to `rd_kafka_commit` inside of
`KafkaCosumer.commitSync` is blocking a cooperative thread.
This PR aims to make `KafkaCosumer.commitSync` non-blocking by using the
callback-based commit API.
Modifications:
* move `commitSync` logic to `KafkaClient`
* replace the blocking invocation to
[rd_kafka_commit](https://docs.confluent.io/platform/current/clients/librdkafka/html/rdkafka_8h.html#ab96539928328f14c3c9177ea0c896c87)
with a callback-based invocation to
[rd_kafka_commit_queue](https://docs.confluent.io/platform/current/clients/librdkafka/html/rdkafka_8h.html#af76a6a73baa9c2621536e3f6882a3c1a)
which is then wrapped inside a `withAsyncThrowingContinuation` statement
* `KafkaClient.consumerClose`: make non-blocking
Motivation:
[rd_kakfa_consumer_close](https://docs.confluent.io/platform/current/clients/librdkafka/html/rdkafka_8h.html#a37b54d329e12d745889defe96e7d043d)
was blocking. This PR proposes using the
[rd_kakfa_consumer_close_queue](https://docs.confluent.io/platform/current/clients/librdkafka/html/rdkafka_8h.html#a9dd5c18bdfed81c8847b259f0a8d498d)
API which is non-blocking and served through the normal poll loop.
We now
Modifications:
* `KafkaClient.consumerClose`: use `rd_kakfa_consumer_close_queue` in
favour of `rd_kakfa_consumer_close`
* create a new variable `KafkaClient.isConsumerClosed` that indicates
if the poll loop needs to continue polling or if it can stop running
* updated state management in `KafkaConsumer` to accomodate for polling
when the `KafkaConsumer` is in the process of closing
Result:
Calling `KafkaClient.consumerClose` is not blocking anymore.
* Review Franz
Modifications:
* introduce new `KafkaConsumer.StateMachine.State` `.finishing` to avoid
retaining `client` in state `.finished`
* rename `KafkaConsumer.shutdownGracefully` to
`KafkaConsumer.triggerGracefulShutdown`
* add note that `KafkaConsumer.commitSync` does not support `Task`
cancellation
0 commit comments