David Jacot created KAFKA-21684:
-----------------------------------

             Summary: Upgrading a classic group fails on a partition assigned 
twice and gives away partitions not revoked yet
                 Key: KAFKA-21684
                 URL: https://issues.apache.org/jira/browse/KAFKA-21684
             Project: Kafka
          Issue Type: Bug
            Reporter: David Jacot
            Assignee: David Jacot


When a member using the consumer protocol joins a classic group, the group is 
upgraded to a consumer group whose members own the partitions of their last 
classic assignment. A partition has a single owner in a consumer group, but the 
last classic assignment can disagree with this in two ways.

A client-side assignor can assign a partition to more than one member. The 
sticky assignors of the Java consumer did it in the past (KAFKA-7026, 
KAFKA-12984), and they still do it after a topic is re-created with fewer 
partitions (KAFKA-21674). The upgrade then fails with an IllegalStateException 
on the second owner of the partition, which is not caught:

{noformat}
Cannot set the epoch of <topic id>-<partition> to <generation> because the 
partition is still owned at epoch <generation>
{noformat}

The joining member gets UNKNOWN_SERVER_ERROR in its ConsumerGroupHeartbeat 
response, which the consumer treats as fatal, and the group stays a classic 
group. Every later attempt fails the same way for as long as the classic 
assignments overlap.

With the cooperative protocol, the assignment of a generation leaves out the 
partitions that move to another member. Their previous owner keeps consuming 
them until it revokes them in its next poll(), and the new owner only gets them 
in the next generation. If the group is upgraded in this window, these 
partitions have no owner in the consumer group, and the first target assignment 
gives them to another member at once. Both members consume them, and can commit 
offsets for them, until the previous owner revokes them.

*Steps to reproduce*, with group.consumer.migration.policy set to upgrade or 
bidirectional (the default since 4.0):
# Two classic consumers join group G, subscribed to topic T, with a custom 
ConsumerPartitionAssignor that assigns T-0 to both. Start a consumer with 
group.protocol=consumer in group G. Its ConsumerGroupHeartbeat fails with 
UNKNOWN_SERVER_ERROR, the consumer fails, and the group coordinator logs 
"Operation consumer-group-heartbeat with ... hit an unexpected exception" with 
the IllegalStateException above.
# Classic consumer C1 with the cooperative-sticky assignor owns T-0 and T-1 in 
group G. Classic consumer C2 joins, and the assignment of the next generation 
gives T-0 to C1 and leaves T-1 out, to give it to C2 in the generation after. 
Before C1 revokes T-1 in its next poll(), start a consumer C3 with 
group.protocol=consumer in group G. The group is upgraded, and the first target 
assignment gives T-1 to C2 or C3 while C1 still consumes it.

*Expected:* the group is upgraded, and each partition has one owner at a time: 
a partition assigned twice ends up with one member, and a partition that a 
member has not revoked yet goes to another member only after the revocation.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to