sanghyeok An created KAFKA-21613:
------------------------------------

             Summary: Kafka Streams can fail to initialize a topology when a 
join connects two existing copartition groups
                 Key: KAFKA-21613
                 URL: https://issues.apache.org/jira/browse/KAFKA-21613
             Project: Kafka
          Issue Type: Bug
          Components: clients, streams
            Reporter: sanghyeok An
            Assignee: sanghyeok An


*Description*

Consider a topology that joins A with B, joins C with D, and then joins the 
original streams B and C. All four repartition topics must have the same 
partition count to satisfy the three joins.

When the topology builder processes the final join, it extends only one of the 
two existing copartition groups. As a result, the Streams group coordinator can 
request different partition counts for the two inputs to a join. When the 
coordinator later sees topics with the counts it requested, it can reject the 
topology because those counts violate the join’s copartitioning requirement.

 

*Reproduction example*

 
{code:java}
StreamsBuilder builder = new StreamsBuilder();
var consumed = Consumed.with(Serdes.String(), Serdes.String());var a = 
builder.stream("input-a", consumed).repartition(Repartitioned.as("a"));
var b = builder.stream("input-b", consumed).repartition(Repartitioned.as("b"));
var c = builder.stream("input-c", consumed).repartition(Repartitioned.as("c"));
var d = builder.stream("input-d", 
consumed).repartition(Repartitioned.as("d"));var window = 
JoinWindows.ofTimeDifferenceWithNoGrace(Duration.ofMinutes(1));
ValueJoiner<String, String, String> combine = (left, right) -> left + ":" + 
right;a.join(b, combine, window).to("out-ab");
c.join(d, combine, window).to("out-cd");
b.join(c, combine, window).to("out-bc");Topology topology = 

builder.build();

{code}
 

builder.build() succeeded, but InternalTopologyBuilder.copartitionGroups() 
returned two overlapping groups, \{A, B} and \{B, C, D}. The coordinator kept A 
and B at one partition when it processed the first group. It then set B, C, and 
D to five partitions when it processed the second group. A remained at one 
partition, leaving the two inputs to a.join(b, ...) with different partition 
counts.

 

If A=1, B=1, C=1, D=5, repartition topic count will A=1, B=5, C=,5, D=5.



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

Reply via email to