[ 
https://issues.apache.org/jira/browse/KAFKA-21188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18145721#comment-18145721
 ] 

sanghyeok An edited comment on KAFKA-21188 at 11/16/26, 2:45 PM:
-----------------------------------------------------------------

[~lucasbru] 

Thanks for your comment! Overall sounds good to me!
{quote}While checking this, I found something I need to correct from my last 
comment. The coordinator only skips the revocation if the heartbeat actually 
carries the owned tasks. {{StreamsGroupHeartbeatRequestManager}} only sends 
{{{}ActiveTasks{}}}, {{StandbyTasks}} and {{WarmupTasks}} when the reconciled 
assignment has changed since the last heartbeat. If they are left out, 
{{CurrentAssignmentBuilder}} assumes the member still owns everything. With a 
partially resolved assignment, that leads to a hang. The client reports [1_0], 
the coordinator moves 0_0 to another member, and the next heartbeat leaves out 
the owned tasks, so the coordinator waits for 0_0 to be revoked. The client 
then acknowledges the partially resolved assignment, but its reconciled 
assignment is still [1_0], so it never sends its owned tasks again. The member 
stays in {{{}UNREVOKED_TASKS{}}}, and the new owner waits for 0_0. The consumer 
doesn’t have this problem because {{ConsumerHeartbeatRequestManager}} compares 
the whole {{{}LocalAssignment{}}}, including the local epoch. Every 
acknowledgement of a partially resolved assignment therefore resends the owned 
partitions. The Streams heartbeat should do the same, so I’d add that to the 
fix together with a test for it.
{quote}
Ah, that’s a good point. I’ll address the following two items in my PR:
 # Include the tasks in the Streams heartbeat when a partial task assignment is 
applied.
 # Consider removing the intermediate state, {{AppliedAssignment}} and 
{{{}RevokedSinceApply{}}}, which currently accounts for failures in the 
revoked/assigned callbacks. I’ll take another look at this together with the 
points you raised.

I also encountered two issues while working on a client-side-only solution, and 
I’d appreciate your thoughts on them:
 # When the Group Coordinator’s metadata changes but the assigned tasks remain 
the same, the client does not perform reconciliation. For example, suppose the 
member epoch is 10, the topic partitions are {{{}[A-0, B-0, B-1, B-2]{}}}, and 
the assigned tasks are {{{}[0_2]{}}}. The client processes task {{{}0_2{}}}, 
with {{[B-2]}} as its assigned partitions. If the member epoch then becomes 11, 
the topic partitions become {{{}[A-0, A-1, A-2, B-0, B-1, B-2]{}}}, and the 
assigned tasks remain {{{}[0_2]{}}}, the client does not reconcile. Its 
assigned partitions therefore remain {{{}[B-2]{}}}. However, if it receives 
{{{}[0_1, 0_2]{}}}, reconciliation takes place and the assigned partitions 
become {{{}[A-1, A-2, B-1, B-2]{}}}. From the Group Coordinator’s perspective, 
an increase in partition counts can change the computed hash and trigger a new 
assignment. However, the client does not know which partition metadata the 
coordinator used. In the current client implementation, the target assignment 
remains unchanged when the assigned tasks are identical, so reconciliation does 
not occur. I believe this could be addressed in a follow-up KIP by having the 
client use partition information provided by the broker.
 # We assume that each task assigned by the Group Coordinator has at least one 
corresponding input partition from a source or repartition topic. The current 
Sticky Task Assignor follows this rule, but user-provided Custom Task Assignors 
may behave differently. I think it would be preferable to make this a 
requirement of the Custom Task Assignor contract and enforce it through 
validation. I find it difficult to envision how a task with no corresponding 
input partitions would operate. Treating such a task as valid and assigning it 
would require broader changes on the Streams client side, and it does not seem 
like a valid task assignment to me.

These are the issues I encountered during implementation, along with the 
current behavior and the reasoning behind it. 
I’d appreciate your thoughts on these points as well!


was (Author: JIRAUSER303328):
[~lucasbru] 

Thanks for your comment! Overall sounds good to me!
{quote}While checking this, I found something I need to correct from my last 
comment. The coordinator only skips the revocation if the heartbeat actually 
carries the owned tasks. {{StreamsGroupHeartbeatRequestManager}} only sends 
{{{}ActiveTasks{}}}, {{StandbyTasks}} and {{WarmupTasks}} when the reconciled 
assignment has changed since the last heartbeat. If they are left out, 
{{CurrentAssignmentBuilder}} assumes the member still owns everything. With a 
partially resolved assignment, that leads to a hang. The client reports [1_0], 
the coordinator moves 0_0 to another member, and the next heartbeat leaves out 
the owned tasks, so the coordinator waits for 0_0 to be revoked. The client 
then acknowledges the partially resolved assignment, but its reconciled 
assignment is still [1_0], so it never sends its owned tasks again. The member 
stays in {{{}UNREVOKED_TASKS{}}}, and the new owner waits for 0_0. The consumer 
doesn’t have this problem because {{ConsumerHeartbeatRequestManager}} compares 
the whole {{{}LocalAssignment{}}}, including the local epoch. Every 
acknowledgement of a partially resolved assignment therefore resends the owned 
partitions. The Streams heartbeat should do the same, so I’d add that to the 
fix together with a test for it.
{quote}
Ah, that’s a good point. I’ll address the following two items in my PR:
 # Include the tasks in the Streams heartbeat when a partial task assignment is 
applied.
 # Consider removing the intermediate state, {{AppliedAssignment}} and 
{{{}RevokedSinceApply{}}}, which currently accounts for failures in the 
revoked/assigned callbacks. I’ll take another look at this together with the 
points you raised.

I also encountered two issues while working on a client-side-only solution, and 
I’d appreciate your thoughts on them:
 # When the Group Coordinator’s metadata changes but the assigned tasks remain 
the same, the client does not perform reconciliation. For example, suppose the 
member epoch is 10, the topic partitions are {{{}[A-0, B-0, B-1, B-2]{}}}, and 
the assigned tasks are {{{}[0_2]{}}}. The client processes task {{{}0_2{}}}, 
with {{[B-2]}} as its assigned partitions.

If the member epoch then becomes 11, the topic partitions become {{{}[A-0, A-1, 
A-2, B-0, B-1, B-2]{}}}, and the assigned tasks remain {{{}[0_2]{}}}, the 
client does not reconcile. Its assigned partitions therefore remain 
{{{}[B-2]{}}}. However, if it receives {{{}[0_1, 0_2]{}}}, reconciliation takes 
place and the assigned partitions become {{{}[A-1, A-2, B-1, B-2]{}}}.

>From the Group Coordinator’s perspective, an increase in partition counts can 
>change the computed hash and trigger a new assignment. However, the client 
>does not know which partition metadata the coordinator used. In the current 
>client implementation, the target assignment remains unchanged when the 
>assigned tasks are identical, so reconciliation does not occur. I believe this 
>could be addressed in a follow-up KIP by having the client use partition 
>information provided by the broker.

 # We assume that each task assigned by the Group Coordinator has at least one 
corresponding input partition from a source or repartition topic. The current 
Sticky Task Assignor follows this rule, but user-provided Custom Task Assignors 
may behave differently.

I think it would be preferable to make this a requirement of the Custom Task 
Assignor contract and enforce it through validation. I find it difficult to 
envision how a task with no corresponding input partitions would operate. 
Treating such a task as valid and assigning it would require broader changes on 
the Streams client side, and it does not seem like a valid task assignment to 
me.

These are the issues I encountered during implementation, along with the 
current behavior and the reasoning behind it. 
I’d appreciate your thoughts on these points as well!

> Merging topics with different partition counts leaves some records 
> unprocessed under the Streams Rebalance Protocol
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: KAFKA-21188
>                 URL: https://issues.apache.org/jira/browse/KAFKA-21188
>             Project: Kafka
>          Issue Type: Bug
>          Components: clients, streams
>            Reporter: sanghyeok An
>            Assignee: sanghyeok An
>            Priority: Major
>
> With {*}group.protocol=streams{*}, merging two topics with different 
> partition counts includes nonexistent partitions in the tasks’ inputs, 
> leaving some records unprocessed.
> *Steps to Reproduce*
> 1. Create topic A with 1 partition({*}0{*}) and topic B with 3 
> partitions({*}0, 1, 2{*}).
> 2. Run the following topology with {*}group.protocol=streams{*}:
> {code:java}
> KStream<String, String> streamA = builder.stream("A");
> KStream<String, String> streamB = builder.stream("B");
> streamA.merge(streamB).to("output");
> {code}
> 3. Produce records to {*}A-0{*}, {*}B-0{*}, {*}B-1{*}, and {*}B-2{*}.
>  * *Expected:* All input records appear in `output`.
>  * *Actual:* Records from `B-1` and `B-2` do not appear in `output`, and the 
> following messages repeatedly reference nonexistent partitions:
> {code:java}
> Requesting the log end offset for A-1 in order to compute lag
> Requesting the log end offset for A-2 in order to compute lag
> {code}
>  
> *Cause*
> StreamsMembershipManager#topicPartitionsForActiveTasks and 
> DefaultStreamsRebalanceListener#toTopicPartitions apply the task’s partition 
> ID to every input topic without checking each topic’s partition count.
> As a result, a task that should include only *B-1* also includes {*}A-1{*}. 
> The same issue occurs for partition ID 2.
> The classic protocol’s PartitionGrouper checks each topic’s partition count 
> and includes only existing partitions. The new protocol’s conversion paths 
> need equivalent handling.



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

Reply via email to