Skip to content
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

Fix multiple sources build side in AdaptiveReorderPartitionedJoin #23454

Merged

Conversation

gaurav8297
Copy link
Member

@gaurav8297 gaurav8297 commented Sep 17, 2024

Description

Fix: #23407

Additional context and related issues

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x) Release notes are required, with the following suggested text:

# General
* Fix possible query failure when `retry_policy` is set to `TASK` and when adaptive join reordering is enabled . ({issue}`23407`)

@cla-bot cla-bot bot added the cla-signed label Sep 17, 2024
@losipiuk
Copy link
Member

Please add add a regression test for this one.

@gaurav8297 gaurav8297 force-pushed the gaurav8297/fix_adaptive_partitioned_join branch from d79a3b3 to 15f7f03 Compare September 19, 2024 03:29
@gaurav8297 gaurav8297 marked this pull request as ready for review September 19, 2024 03:29
Copy link
Member

@losipiuk losipiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seem fine - but hard to follow.
So more idiot-friendly comments would be nice.

@@ -157,70 +161,57 @@ private static boolean isBuildSideLocalExchangeNode(ExchangeNode exchangeNode, S
&& exchangeNode.getPartitioningScheme().getHashColumn().isEmpty();
}

private static JoinNode removeLocalExchangeFromBuildSide(JoinNode joinNode, ExchangeNode localExchangeNode, Context context)
private static JoinNode flipJoinAndFixLocalExchanges(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we comply to SystemSessionProperties.isUseExactPartitioning here?

Copy link
Member Author

@gaurav8297 gaurav8297 Sep 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is only applicable for remote exchange and in our case we only care about changing local exchange. Additionally, we have a check (!expectedRightProperties.isSatisfiedBy(rightProperties)) using deriveStreamPropertiesRecursively so it won't add extra local exchange if not needed.

Comment on lines 260 to 262
if (node.getStep() == PARTIAL) {
return rewriteSources(this, node, context);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same as visitPlan(node, ctx);. Looks like you can just drop if. Or whole visitAggregation actually

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some more checks. PTAL

@Override
public PlanNode visitExchange(ExchangeNode node, RewriteContext<Void> ctx)
{
// if there are multiple sources with round-robin exchange, replace it with partitioned exchange
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if there is partitined exchange? Looks like we will add another one even if not needed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's a partitioned exchange which comply with partitioning scheme needed for join then we won't add anything because of this check. !expectedRightProperties.isSatisfiedBy(rightProperties)

@gaurav8297 gaurav8297 force-pushed the gaurav8297/fix_adaptive_partitioned_join branch from 15f7f03 to cf6e515 Compare September 20, 2024 05:24
@losipiuk losipiuk merged commit 6c25ebf into trinodb:master Sep 20, 2024
94 checks passed
@github-actions github-actions bot added this to the 459 milestone Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

fault_tolerant_execution_adaptive_join_reordering_enabled is causing previous working queries to fail
2 participants