-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-14834: [11/N] Update table joins to identify out-of-order records with isLatest
#13609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8ac5565
9314f2f
18a6c01
4d021d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,8 @@ | |
| import org.apache.kafka.streams.kstream.internals.foreignkeyjoin.SubscriptionReceiveProcessorSupplier; | ||
| import org.apache.kafka.streams.kstream.internals.foreignkeyjoin.SubscriptionWrapper; | ||
| import org.apache.kafka.streams.kstream.internals.foreignkeyjoin.SubscriptionWrapperSerde; | ||
| import org.apache.kafka.streams.kstream.internals.graph.ForeignTableJoinNode; | ||
| import org.apache.kafka.streams.kstream.internals.graph.ForeignJoinSubscriptionSendNode; | ||
| import org.apache.kafka.streams.kstream.internals.graph.KTableKTableJoinNode; | ||
| import org.apache.kafka.streams.kstream.internals.graph.ProcessorGraphNode; | ||
| import org.apache.kafka.streams.kstream.internals.graph.ProcessorParameters; | ||
|
|
@@ -804,6 +806,7 @@ private <VO, VR> KTable<K, VR> doJoin(final KTable<K, VO> other, | |
| kTableKTableJoinNode.setOutputVersioned(isOutputVersioned); | ||
|
|
||
| builder.addGraphNode(this.graphNode, kTableKTableJoinNode); | ||
| builder.addGraphNode(((KTableImpl<?, ?, ?>) other).graphNode, kTableKTableJoinNode); | ||
|
|
||
| // we can inherit parent key serde if user do not provide specific overrides | ||
| return new KTableImpl<K, Change<VR>, VR>( | ||
|
|
@@ -1098,7 +1101,7 @@ private <VR, KO, VO> KTable<K, VR> doJoinOnForeignKey(final KTable<KO, VO> forei | |
| //not be done needlessly. | ||
| ((KTableImpl<?, ?, ?>) foreignKeyTable).enableSendingOldValues(true); | ||
|
|
||
| //Old values must be sent such that the ForeignJoinSubscriptionSendProcessorSupplier can propagate deletions to the correct node. | ||
| //Old values must be sent such that the SubscriptionSendProcessorSupplier can propagate deletions to the correct node. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This, and a few other similar renames in comments, are unrelated to this PR but included as cleanup from #13589.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you! -- Could we do a small follow up for 3.4 branch to get it backported?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure thing: #13610 |
||
| //This occurs whenever the extracted foreignKey changes values. | ||
| enableSendingOldValues(true); | ||
|
|
||
|
|
@@ -1138,22 +1141,18 @@ private <VR, KO, VO> KTable<K, VR> doJoinOnForeignKey(final KTable<KO, VO> forei | |
| keySerde | ||
| ); | ||
|
|
||
| final KTableValueGetterSupplier<K, V> primaryKeyValueGetter = valueGetterSupplier(); | ||
| final StatefulProcessorNode<K, Change<V>> subscriptionSendNode = new StatefulProcessorNode<>( | ||
| final ProcessorGraphNode<K, Change<V>> subscriptionSendNode = new ForeignJoinSubscriptionSendNode<>( | ||
| new ProcessorParameters<>( | ||
| new SubscriptionSendProcessorSupplier<>( | ||
| foreignKeyExtractor, | ||
| subscriptionForeignKeySerdePseudoTopic, | ||
| valueHashSerdePseudoTopic, | ||
| foreignKeySerde, | ||
| valueSerde == null ? null : valueSerde.serializer(), | ||
| leftJoin, | ||
| primaryKeyValueGetter | ||
| leftJoin | ||
| ), | ||
| renamed.suffixWithOrElseGet("-subscription-registration-processor", builder, SUBSCRIPTION_REGISTRATION) | ||
| ), | ||
| Collections.emptySet(), | ||
| Collections.singleton(primaryKeyValueGetter) | ||
| ) | ||
| ); | ||
| builder.addGraphNode(graphNode, subscriptionSendNode); | ||
|
|
||
|
|
@@ -1219,13 +1218,13 @@ private <VR, KO, VO> KTable<K, VR> doJoinOnForeignKey(final KTable<KO, VO> forei | |
| ); | ||
| builder.addGraphNode(subscriptionReceiveNode, subscriptionJoinNode); | ||
|
|
||
| final StatefulProcessorNode<KO, Change<VO>> foreignTableJoinNode = new StatefulProcessorNode<>( | ||
| final StatefulProcessorNode<KO, Change<VO>> foreignTableJoinNode = new ForeignTableJoinNode<>( | ||
| new ProcessorParameters<>( | ||
| new ForeignTableJoinProcessorSupplier<>(subscriptionStore, combinedKeySchema, foreignKeyValueGetter), | ||
| new ForeignTableJoinProcessorSupplier<>(subscriptionStore, combinedKeySchema), | ||
| renamed.suffixWithOrElseGet("-foreign-join-subscription", builder, SUBSCRIPTION_PROCESSOR) | ||
| ), | ||
| Collections.singleton(subscriptionStore), | ||
| Collections.singleton(foreignKeyValueGetter) | ||
| Collections.emptySet() | ||
| ); | ||
| builder.addGraphNode(((KTableImpl<KO, VO, ?>) foreignKeyTable).graphNode, foreignTableJoinNode); | ||
|
|
||
|
|
@@ -1259,6 +1258,7 @@ private <VR, KO, VO> KTable<K, VR> doJoinOnForeignKey(final KTable<KO, VO> forei | |
| resultSourceNodes.add(foreignResponseSource.nodeName()); | ||
| builder.internalTopologyBuilder.copartitionSources(resultSourceNodes); | ||
|
|
||
| final KTableValueGetterSupplier<K, V> primaryKeyValueGetter = valueGetterSupplier(); | ||
| final StatefulProcessorNode<K, SubscriptionResponseWrapper<VO>> responseJoinNode = new StatefulProcessorNode<>( | ||
| new ProcessorParameters<>( | ||
| new ResponseJoinProcessorSupplier<>( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why it's currently the case that primary-key table-table join nodes only have one parent, instead of two. Seems more correct to have two, and the GraphNode mechanism for determining whether the joining table is versioned or not will not work without this parent connection.
I have verified that there is no change to the built topology, so AFAICT this addition is internal-only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. Seems to be incorrect, but did apparently not surface as a bug. Nice fix!