[
https://issues.apache.org/jira/browse/KAFKA-21188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18143001#comment-18143001
]
sanghyeok An commented on KAFKA-21188:
--------------------------------------
[~lucasbru]
Thanks for your comments! I agree that reporting only successfully reconciled
tasks in heartbeats would be a better approach!
I have been thinking about edge cases where some active tasks cannot be applied
because metadata is unavailable, or where a callback fails. These seem to be
cases that the current state machine may not fully handle. Two scenarios came
to mind:
# Member A receives tasks {{[0_0, 0_1]}} and applies their partitions to the
main consumer’s {{{}SubscriptionState{}}}, but the assignment callback fails,
possibly after partially applying the assignment. Assuming no previous
successful assignment, A would report an empty owned-task set. After member B
joins, the coordinator may assign {{0_1}} to B once it processes A’s empty
ownership report against the new target assignment. When A receives
{{{}[0_0]{}}}, it attempts to revoke {{{}0_1{}}}, but that callback could also
fail. This could leave task {{0_1}} present on both members temporarily.
However, A’s newly assigned partitions remain non-fetchable because
{{pendingOnAssignedCallback}} is not cleared after the assignment callback
fails. Once revocation starts, {{pendingRevocation}} also prevents fetching.
Therefore, the task’s presence on both members would not necessarily cause
concurrent input processing. From that perspective, this seems compatible with
at-least-once processing, although A would still need to clean up its remaining
task resources.
# Member A successfully reconciles {{[0_0, 0_1]}} and starts processing both
tasks. The coordinator subsequently moves {{0_1}} to member B, but A’s
revocation callback fails. In this case, A updates its target assignment to
{{[0_0]}} but retains its previous successfully reconciled assignment and
continues reporting ownership of {{{}0_1{}}}. The coordinator would therefore
wait for A to confirm revocation before assigning {{0_1}} to B.
Based on these scenarios, reporting successfully reconciled tasks seems
reasonable from an at-least-once perspective, provided that partially applied
tasks remain tracked for cleanup.
Does this reasoning make sense?
Are there any other edge cases you think would be worth considering? Please let
me know your thoughts~!
PS. I am also taking a closer look at your comments to better understand the
Group Coordinator’s perspective. Thank you for your patience while I build my
understanding!
> 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)