-
Notifications
You must be signed in to change notification settings - Fork 141
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
breaking: Do not run user rebalance listener on same thread runtime #1205
breaking: Do not run user rebalance listener on same thread runtime #1205
Conversation
Can we say this is an 'addition' iso of a 'correction'? 😉 |
We need to change some documentation as well. |
For example we can remove this remark in
|
I remember now why I didn't do this in the context of #1098. This is because running on another executor means you can't use the kafka consumer, at least not the one that is passed in. You have to use I see these options:
|
Ah that is good to know. I would be in favour of #4. Any downsides to that, use cases where users explicitly want to commit offsets? I suppose that is now supported by |
zio-kafka/src/main/scala/zio/kafka/consumer/internal/Runloop.scala
Outdated
Show resolved
Hide resolved
zio-kafka/src/main/scala/zio/kafka/consumer/internal/Runloop.scala
Outdated
Show resolved
Hide resolved
Me as well.
Exactly. What else could someone be doing in the rebalance listener that requires the consumer? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🙂
RebalanceListener
are now of typeSet[TopicPartition] => Task[Unit]
(this used to be(Set[TopicPartition], RebalanceConsumer) => Task[Unit]
).Since #1098 the rebalance listener runs on a special same-thread-runtime. This is also true for the user provided rebalance listener. The same-thread-runtime is not convenient to use at all; a lot of care must be taken to keep the zio fiber on the same thread. Note, the only reason for using the same-thread-runtime is to enforce the same-thread access that is required by the kafka consumer (see #1098 for more details). However, the kafka consumer that is passed to the rebalance listener should be used via the internal
ConsumerAccess
.Since #1098 it is no longer necessary to use the rebalance listener to commit offsets, this is done with the
rebalanceSafeCommits
feature. We do not see other use cases for the kafka consumer from inside the rebalance listener.For these reasons, this change runs user provided rebalance listener on the regular runtime again. In addition, access to the kafka consumer from within the user rebalance listeners is removed.