Repository navigation
Skip read-in-order-through-join optimization for parallel replicas - #98685
Merged
devcrafter merged 9 commits intoMar 5, 2026
Merged
Conversation
With parallel replicas, the `read_in_order_through_join` optimization can produce different results on the initiator and remote replicas (due to differences in plan construction such as AST optimizations), leading to coordination mode mismatch: "Replica decided to read in Default mode, not in WithOrder". Skip this optimization for parallel replicas when it goes through a JOIN, for all three variants: sorting, aggregation, and distinct. This is consistent with the existing check that skips read-in-order for parallel replicas in the Union case. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=98548&sha=8a781939137bab7b45291ac4d013e5f444ccf41a&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Contributor
|
Workflow [PR], commit [934e463] Summary: ❌
|
Member
Author
|
@devcrafter, this effectively removes the wrong optimization (read-in-order through JOIN with parallel replicas). |
…icas The test verifies that the `read_in_order_through_join` optimization is correctly skipped when parallel replicas are enabled, for all three variants: sorting, aggregation-in-order, and distinct-in-order. It checks via EXPLAIN that ReadType changes from InOrder (without parallel replicas) to Default (with parallel replicas), and also runs the actual queries with failpoints to detect any coordination mode mismatch. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…as-read-in-order-through-join
devcrafter
reviewed
Mar 4, 2026
devcrafter
approved these changes
Mar 4, 2026
devcrafter
enabled auto-merge
March 4, 2026 17:07
Member
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
read_in_order_through_joinoptimization whenReadFromMergeTreehas parallel replicas enabledWith parallel replicas, the initiator's local plan is built with
ignoreASTOptimizations()while the remote replica is not, which can cause different plan structures. Whenread_in_order_through_joinapplies on one side but not the other, they end up with different coordination modes (WithOrder vs Default), triggering a LOGICAL_ERROR inParallelReplicasReadingCoordinator.This fix is consistent with the existing check that already skips read-in-order for parallel replicas in the Union case (lines 1409-1416 of
optimizeReadInOrder.cpp).CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=98548&sha=8a781939137bab7b45291ac4d013e5f444ccf41a&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29
#98548
Test plan
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix LOGICAL_ERROR "Replica decided to read in Default mode, not in WithOrder" when using
read_in_order_through_joinwith parallel replicas.🤖 Generated with Claude Code
Version info
26.3.1.430