You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Sophie Blee-Goldman (Jira)" <ji...@apache.org> on 2019/10/30 04:00:01 UTC
[jira] [Comment Edited] (KAFKA-9112) Combine streams `onAssignment`
with `partitionsAssigned` task creation
[ https://issues.apache.org/jira/browse/KAFKA-9112?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16962498#comment-16962498 ]
Sophie Blee-Goldman edited comment on KAFKA-9112 at 10/30/19 3:59 AM:
----------------------------------------------------------------------
I agree with this ticket 100% and had the same thought a million times while working on KIP-429. I would personally vote to actually combine the ConsumerRebalanceListener and ConsumerPartitionAssignor in some way, or at least give a number of the assignor's current responsibilities over to the listener. In complex systems they need to share state and synchronize, which is made worse by the different listener callback semantics of the two rebalance protocols.
eg in eager, onPartitionsRevoked is always called before ConsumerPartitionAssignor#subscriptionUserdata and therefore the assignor can count on whatever state being "updated" as of the new rebalance – but in a cooperative rebalance, ConsumerPartitionAssignor#subscriptionUserdata might be the first and only method called at the start of the rebalance (but it also might not be!). It's awkward that subscriptionUserdata has to reason about how the state may or may not have been updated, according to which protocol – when its job should just be to wrap up some data and encode it.
The assignor's current role extends way beyond just assignment, and is just as responsible for updating state and reacting to rebalances as the listener. We should try and define a clear separation of responsibilities – maybe one class that reacts to the occurrence of a rebalance – regardless of protocol, ie through onRebalanceBegin and onRebalanceEnd for example – plus the usual callbacks to react to the specific partition-ownership events (eg onPartitionsRevoked). This one _reacts_ to a rebalance, keeps state, and tells the user/app (eg Streams) how to then update its own state and react accordingly – this is a true rebalance listener
And another class should be responsible for the actual assignment, such as which assignment strategy to support and encode, and of course implementing the actual assignment algorithm. This one should most likely be almost, if not entirely, stateful – any state it needs can come from the listener, but should not be stored or updated by this class. It doesn't react to events, it performs functions – assignment, or encoding the subscription, etc. – it's a pure assignor
was (Author: ableegoldman):
I agree with this ticket 100% and had the same thought a million times while working on KIP-429. I would personally vote to combine the ConsumerRebalanceListener and ConsumerPartitionAssignor completely (or at least give a number of the assignor's current responsibilities over to the listener). In complex systems they need to share state and synchronize, which is made worse by the different listener callback semantics of the two rebalance protocols.
eg in eager, onPartitionsRevoked is always called before ConsumerPartitionAssignor#subscriptionUserdata and therefore the assignor can count on whatever state being "updated" as of the new rebalance – but in a cooperative rebalance, ConsumerPartitionAssignor#subscriptionUserdata might be the first and only method called at the start of the rebalance (but it also might not be!)
The assignor's current role extends way beyond just assignment, and is just as responsible for updating state and reacting . to rebalances as the listener. We should try and define a clear separation of responsibilities – maybe one class that reacts to the occurrence of a rebalance – regardless of protocol, ie through onRebalanceBegin and onRebalanceEnd for example – plus the usual callbacks to react to the specific partition-ownership events (eg onPartitionsRevoked). This one _reacts_ to a rebalance, keeps state, and tells the user/app (eg Streams) how to then update its own state and react accordingly – this is a true rebalance listener
And another class should be responsible for the actual assignment, such as which assignment strategy to support and encode, and of course implementing the actual assignment algorithm. This one should most likely be almost, if not entirely, stateful – any state it needs can come from the listener, but should not be stored or updated by this class. It doesn't react to events, it performs functions – assignment, or encoding the subscription, etc. – it's a pure assignor
> Combine streams `onAssignment` with `partitionsAssigned` task creation
> ----------------------------------------------------------------------
>
> Key: KAFKA-9112
> URL: https://issues.apache.org/jira/browse/KAFKA-9112
> Project: Kafka
> Issue Type: Improvement
> Components: streams
> Reporter: Boyang Chen
> Priority: Major
>
> Task manager needs to call `createTasks` inside partitionsAssigned callback, which is after the `onAssignment` callback for assignor. This means during task creation we rely on the status change based on the intermediate data structures populated by a different callback, which is hard to reason about. We should consider consolidate logics to either one of the callbacks, prefer `onAssignment` as it contains full information needed.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)