Repository navigation
Fix unknown-stream LOGICAL_ERROR in parallel replicas with projection short-circuit - #111689
Conversation
… short-circuit When a projection optimization fully answers a read on the initiator's parallel-replicas local plan, it replaces the ReadFromMergeTree step with a prepared source. That step's initializePipeline() then never runs, so the empty-ranges announcement it would send to the coordinator (added in the read_in_order reimplementation to prevent followers from initializing the coordinator with a divergent plan) is skipped and the coordinator registers no stream for the table. A follower that does not take the same short-circuit then requests a stream the coordinator never registered, tripping 'Got read request from replica N for unknown stream ...' (LOGICAL_ERROR). Four fully short-circuiting paths replace the read this way: the exact-count and minmax-count aggregate projections, and a stored aggregate or normal projection whose read selects zero ranges. Announce the empty read from the projection optimizer when the short-circuit leaves no parent parts, reusing the same mechanism initializePipeline() uses. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-author-slot-4:20260723-192900 |
Internal second-model review — adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 4 rounds: 1 full pass + 3 stateful re-reviews as the fix widened; all findings verified against the code before acting).
Severity: ❌ blocker / Session id: cron:clickhouse-author-slot-4:20260723-192900 |
|
cc @nickitat @devcrafter — could you review this? It fixes the parallel-replicas coordinator |
…-replicas-unknown-stream-exact-count # Conflicts: # src/Processors/QueryPlan/ReadFromMergeTree.h
|
Workflow [PR], commit [370001d] Summary: ✅
AI ReviewSummaryThis PR fixes the parallel-replicas Final Verdict✅ No new findings. |
The master merge renamed ParallelReadingExtension::sendInitialRequest's second parameter from 'ranges' to 'description', so the inline argument comment in announceEmptyReadRangesToCoordinatorIfInitiator no longer matched the parameter name. arm_tidy enforces bugprone-argument-comment as -warnings-as-errors, which stopped the build. Comment-only change: /*ranges=*/ -> /*description=*/. Co-Authored-By: Claude Opus 4.8 <[email protected]>
CI finish ledger - f494a22Every failure below has an owner.
Session id: cron:our-pr-ci-monitor:20260724-223000 |
CI finish ledger - f494a22Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20260726-163000 |
…-replicas-unknown-stream-exact-count
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 87/88 (98.86%) · Uncovered code |
Closes: #110518
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix a
LOGICAL_ERROR(Got read request from replica N for unknown stream ...) that could abort the server when reading with parallel replicas and the query is fully answered by a projection optimization (exact-count, minmax-count, or a stored aggregate/normal projection selecting no ranges) on the initiator.Description
Found by the fuzzer (issue #110518, STID 5217-5b3d); recurring on master and PRs (e.g. the
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel)job: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=4d08ee5cf17aeb2983bdf383783ea6c035079de4&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_llvm_coverage%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29 ).Root cause: under parallel replicas with a local plan, the initiator normally announces an empty read set to the coordinator when index analysis leaves no ranges, so followers do not initialize the coordinator with a divergent plan (added in the read-in-order reimplementation). When a projection optimization fully replaces the initiator's
ReadFromMergeTreewith aReadFromPreparedSource, that step'sinitializePipeline()never runs and the announcement is skipped, so the coordinator registers no stream for the table. A follower that does not take the same short-circuit then requests a stream the coordinator never registered, throwingGot read request from replica N for unknown stream ...atParallelReplicasReadingCoordinator::handleRequest.Four fully short-circuiting paths replace the read this way: the exact-count and minmax-count aggregate projections, and a stored aggregate or normal projection whose read selects zero ranges (
readFromPartsreturns an empty step). Fix: when the short-circuit leaves no parent parts, announce the empty read from the projection optimizer, reusing the same mechanisminitializePipeline()uses. The announcement is a no-op unless this is the initiator's local plan under parallel replicas. When a projection is read through its ownReadFromMergeTree(parent parts remain, or the projection read is non-empty), that step announces the base-table stream itself and the new call does not fire.The bug is a same-version initiator/follower plan divergence that a homogeneous single-server test cluster cannot produce on its own, so the regression test uses a fail point (
parallel_replicas_skip_aggregate_projection_on_follower) to force a follower to skip the short-circuit while the initiator takes it. Without the fix each of the four paths aborts the server with the exact error; with it the queries return correct results.