[
https://issues.apache.org/jira/browse/KAFKA-21188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18146160#comment-18146160
]
Lucas Brutschy commented on KAFKA-21188:
----------------------------------------
I agree, I’d leave deleting and recreating source topics while the application
is running unsupported. It’s already covered for the most part: when a source
topic is deleted, the coordinator stops assigning tasks and reports
MISSING_SOURCE_TOPICS, and the client fails with a MissingSourceTopicException
after two heartbeat intervals, the same as with the classic protocol. The only
way around that is deleting and recreating the topic within about one heartbeat
interval, before the coordinator refreshes the group’s metadata. Even then, the
committed offsets, state stores and changelogs still refer to the old topic,
which is why changing the partition count of an input topic already requires
stopping the application and running the application reset tool. I don’t think
we need special handling on the client for it. If the docs on the reset tool
don’t make the delete/recreate case explicit, a short note there would be good.
It does affect one detail in the PR, though. topicPartitionsCache keeps the
highest partition count ever seen for the lifetime of the process, so after a
recreation with fewer partitions, a later assignment would still use the old
count and assign nonexistent partitions again. I’d tie the guard to the current
assignment instead: use the count a task was reconciled with only while that
task stays assigned. When the topic is deleted, the assignment becomes empty
and the old counts go away with it. With the KIP, this problem goes away
completely, since the partition counts come from the coordinator and a
recreated topic gets a new topic ID.
> 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)