[
https://issues.apache.org/jira/browse/KAFKA-21674?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
RITIK KUMAR JAISWAL reassigned KAFKA-21674:
-------------------------------------------
Assignee: RITIK KUMAR JAISWAL
> Sticky assignors assign partitions twice or fail when a member owns a
> partition that no longer exists
> -----------------------------------------------------------------------------------------------------
>
> Key: KAFKA-21674
> URL: https://issues.apache.org/jira/browse/KAFKA-21674
> Project: Kafka
> Issue Type: Bug
> Reporter: David Jacot
> Assignee: RITIK KUMAR JAISWAL
> Priority: Major
>
> When the leader of a classic consumer group computes the assignment with the
> StickyAssignor or the CooperativeStickyAssignor, the assignor keeps each
> partition that a member reports as owned if the partition's topic is in the
> leader's metadata. It doesn't check the partition number. After a topic is
> deleted and created again with fewer partitions, a member can report a
> partition that no longer exists, for example T-3 when T now has 2 partitions.
> AbstractStickyAssignor computes the unassigned partitions by walking the
> sorted owned partitions alongside the sorted partitions of the subscribed
> topics, and it expects every owned partition to be among them. The walk never
> gets past an owned partition that no longer exists, so every owned partition
> sorted after it also counts as unassigned and is assigned a second time.
> Impact:
> * A partition is assigned to two members, and both consume it.
> * A member is assigned a partition that doesn't exist, or the same partition
> twice.
> * When all members subscribe to the same topics, the assignment can fail with
> IllegalStateException: "No more unfilled consumers to be assigned." The
> leader's poll() throws it, and the following rebalances fail the same way
> while members still report the partition.
> A member reports such a partition, for example, when the topic is deleted and
> created again between two metadata refreshes of the leader. The leader sees
> the partition count drop and triggers a rebalance. Cooperative members still
> own the old partitions, because they revoke only the partitions of topics
> that they no longer subscribe to. Eager members revoke all their partitions
> before they rejoin, but the user data of the StickyAssignor still lists them.
> The RangeAssignor and the RoundRobinAssignor don't use the owned partitions
> and aren't affected.
> *Steps to reproduce*
> # Call CooperativeStickyAssignor#assign with topic a with 1 partition and
> topic b with 4 partitions, and two members in generation 1 subscribed to a
> and b: C1 owns a-0, b-0 and b-2, and C2 owns a-1, b-1 and b-3.
> # The assignment fails with IllegalStateException: "No more unfilled
> consumers to be assigned."
> With two more members C3 and C4 that own nothing, the same call returns
> {C1=[a-0, b-0], C2=[a-1], C3=[b-0], C4=[]}: b-0 goes to C1 and C3, and C2
> gets a-1, which doesn't exist.
> With topic a with 2 partitions and topic c with 1 partition, C1 subscribed to
> a and owning a-0 and a-1, and C2 subscribed to a and c and owning c-0 and
> c-1, the CooperativeStickyAssignor returns {C1=[a-0, a-1, a-0], C2=[c-0, c-1,
> a-1]}: a-1 goes to C1 and C2, C1 gets a-0 twice, and C2 gets c-1, which
> doesn't exist. The StickyAssignor returns the same assignment when the owned
> partitions are in its user data.
> *Expected:* the assignors ignore owned partitions that don't exist, assign
> each partition to one member at most, and don't throw.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)