orca: fall back on replicated CTE only when consumed in 2+ slices#398
Draft
Alena0704 wants to merge 3 commits into
Draft
orca: fall back on replicated CTE only when consumed in 2+ slices#398Alena0704 wants to merge 3 commits into
Alena0704 wants to merge 3 commits into
Conversation
Alena0704
marked this pull request as draft
July 3, 2026 11:45
Only a replicated CTE consumed in 2+ different slices hangs, not any cross-slice consumer. Narrow the fallback check to that case.
Alena0704
force-pushed
the
relax-shareinput-walker
branch
from
July 12, 2026 23:12
6eb53c2 to
3d01cbc
Compare
FHasCrossSliceReplicatedCTEConsumer modeled slice assignment on the ORCA CExpression tree, before DXL/Plan translation.
Alena0704
force-pushed
the
relax-shareinput-walker
branch
from
July 13, 2026 08:07
ac411ad to
c52c0a4
Compare
…verage A cross-slice ShareInputScan only executes correctly when its producer and consumer gangs run on the same set of segments: the writer on each producing segment waits for an ack from a reader on that same segment (nodeShareInputScan.c). When the two slices cover different segment sets -- e.g. a DISTRIBUTED REPLICATED CTE materialized on all segments but consumed in a single-segment slice under a Gather 1:1 -- a writer waits for an ack that never arrives and the query hangs to statement_timeout. Detect this on the final plan, where per-slice segment coverage is actually known. apply_shareinput_xslice() already walks the plan with a motId stack; carry a parallel stack of each slice's coverage key (SINGLETON segindex, or "all segments", mirroring how FillSliceTable() sizes an ORCA plan's gangs). When a share is marked cross-slice, compare the producer's and consumer's coverage; if they differ (and the share is not a QD share, which pass 4 relocates onto the QD), set a hazard flag. optimize_query() then discards the ORCA plan and lets the Postgres planner plan the query.
Alena0704
force-pushed
the
relax-shareinput-walker
branch
from
July 13, 2026 10:09
c52c0a4 to
58c9933
Compare
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.
orca: fall back on replicated CTE only when consumed in 2+ slices
Only a replicated CTE consumed in 2+ different slices hangs, not any
cross-slice consumer. Narrow the fallback check to that case