Fix UPDATE with parallel replicas in MergeTree#104255
Conversation
|
Could you please edit your commits to include your email from GitHub? |
Mutation source reads build a synthetic `SELECT` without a table expression, so legacy parallel-replica query rewriting must not be used for them. Mark these reads through `SelectQueryInfo::parallel_replicas_disabled` and honor that flag in `StorageMergeTree` and `StorageReplicatedMergeTree` before entering the legacy parallel-replica paths. Adds a regression test for #104197.
982a8c2 to
cd14db7
Compare
|
Workflow [PR], commit [7911ab3] Summary: ✅
AI ReviewSummaryThis PR disables Final Verdict✅ No blocking or major review findings. The earlier inline concern about |
Per review feedback from @devcrafter: instead of plumbing a new `SelectQueryInfo` flag through `StorageMergeTree` and `StorageReplicatedMergeTree`, disable parallel replicas directly on the per-mutation context in `MutationsInterpreter`. Mutation source reads build a synthetic `SELECT` without a table expression, so the legacy parallel-replica query rewriting must not be used for them. Setting `enable_parallel_replicas` to 0 on the mutation context covers both the task-based and custom-key paths uniformly. The `parallel_replicas_disabled` field of `SelectQueryInfo` that the previous approach relied on has since been removed from master. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The crash only happens on the legacy (non-analyzer) parallel-replica path in `StorageMergeTree`. Force `enable_analyzer = 0` so the test reliably reproduces it instead of depending on randomized settings. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Addressed @devcrafter's feedback and rebased onto current Reworked the fix as suggested. Instead of plumbing a /// Mutation source reads build a synthetic `SELECT` without a table expression,
/// so parallel replicas must not be used for them.
new_context->setSetting("enable_parallel_replicas", Field(0));This is the single chokepoint all Verification (local non-replicated
I also added (@www-dev-1 — the request to set your GitHub email on the commits is still on the original commit; that one needs to be done from your side.) |
`StorageMergeTree::read` only enters the legacy parallel-replica path that crashed when `canUseTaskBasedParallelReplicas` holds, which requires `automatic_parallel_replicas_mode == 0`. `clickhouse-test` randomizes `automatic_parallel_replicas_mode` to `2` in some runs, which would bypass the path under test and let the regression test pass without the fix. Pin it to `0` so the test deterministically exercises the legacy path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Merged current The sole CI red — @groeneai, please investigate the failure https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104255&sha=a171461d9fa04f80eee52bf67ca38389bebd3e16&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%29 and provide a fix in a separate PR. If a fix for #106649 is already in progress, link it here. |
|
Linking the in-flight fix: PR #106025 addresses STID 4697-4326 / Issue #106649 ( |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 5/5 (100.00%) | Lost baseline coverage: none · Uncovered code |
|
@groeneai could you create new PR with the same fix? I can't simply reopen PR since @LambertArm has deleted his repository. |
Lightweight UPDATE on a non-replicated MergeTree table with legacy parallel replicas enabled crashed the server with a SEGV (issue ClickHouse#104197). Mutation source reads build a synthetic SELECT without a table expression. When the legacy parallel-replica path runs for such a query, ClusterProxy::rewriteSelectQuery constructs a DatabaseAndTableWithAlias from a missing table expression and dereferences a null AST pointer (DatabaseAndTableWithAlias.cpp:60), so the server crashes inside MutationsInterpreter::Source::read -> StorageMergeTree::read -> executeQueryWithParallelReplicas. Disable parallel replicas directly on the per-mutation context in the MutationsInterpreter constructor, which is the single chokepoint all constructors delegate to. Setting enable_parallel_replicas to 0 there covers both the task-based and custom-key paths uniformly, and leaves the storage read methods untouched. Adds a regression test pinning enable_analyzer = 0 (the crash is on the legacy non-analyzer path) and automatic_parallel_replicas_mode = 0 (so canUseTaskBasedParallelReplicas enters that path; clickhouse-test otherwise randomizes it and could bypass the code under test). Recreates PR ClickHouse#104255 by @LambertArm (approved by @devcrafter); the original author deleted their repository, so it could not be reopened. Closes ClickHouse#104197. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Closes #104197.
Mutation source reads build a synthetic
SELECTwithout a table expression, so legacy parallel-replica query rewriting must not be used for them.Mark these reads through
SelectQueryInfo::parallel_replicas_disabledand honor that flag inStorageMergeTreeandStorageReplicatedMergeTreebefore entering the legacy parallel-replica paths.Adds a regression test for #104197.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix lightweight
UPDATEqueries with legacy parallel replicas enabled for non-replicatedMergeTreetables.Documentation entry for user-facing changes