[
https://issues.apache.org/jira/browse/KAFKA-21188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18141861#comment-18141861
]
Lucas Brutschy commented on KAFKA-21188:
----------------------------------------
Great, thanks for taking on both!
On your two questions: I’d report only [1_0], and I don’t think that conflicts
with KIP-1071. The heartbeat already distinguishes between assigned and owned
tasks. {{{}ActiveTasks{}}}, {{StandbyTasks}} and {{WarmupTasks}} in the request
are the tasks the client currently owns, and the coordinator keeps track of
what it assigned separately. Today the client only reports a task once
{{onTasksAssigned}} has run for it, so while a reconciliation waits for its
callback, the client already reports only part of its target assignment. A task
waiting for metadata is the same situation: it’s assigned, but not owned yet.
This is also what the consumer does in KIP-848, where a partially resolved
assignment is acknowledged by reporting only the partitions the consumer could
resolve. The unit of assignment is different, but assigned vs. owned works the
same way.
Reporting [0_0] as owned would also make the coordinator behave incorrectly. If
the target assignment changes and moves 0_0 to another member, the coordinator
only waits for a revocation if the current member reports the task as owned
(see {{CurrentAssignmentBuilder}} in the group coordinator). If it isn’t
reported, 0_0 goes straight to the new owner. That’s the right outcome, since
the task never ran on the first member. If we reported it, the new owner would
wait for the revocation of a task that was never started. The coordinator also
relies on owned tasks for things like warm-up tasks, so reporting a task the
client isn’t running would make that information wrong.
Two things to watch for in the implementation:
- A task is only reconciled once the partition counts of all source topics of
its subtopology are known. Otherwise, none of its partitions are assigned, not
even those of topics whose count is already known. So no partition of 0_0
becomes fetchable while 0_0 waits.
- While the client waits for metadata, the coordinator may move 0_0 to another
member. Once the metadata arrives, the client must reconcile against its latest
target assignment and not create 0_0 from an older one. Tests for both cases
would be good.
Happy to discuss once you’ve had time to go through it.
> 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)