Repository navigation
Run lightweight UPDATE ON CLUSTER on one replica per shard - #122393
Conversation
|
cc @zlareb1 could this please be tagged can be tested? |
|
Workflow [PR], commit [0a1347c] Summary: ✅
AI ReviewSummaryThis PR fixes the Final Verdict✅ No findings. LLVM Coverage ReportMeasured on commit 0a1347c.
Changed lines: Changed C/C++ lines covered: 11/11 (100.00%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 12 s compile time in total, 7 of them have a recent master baseline. |
|
cc @zlareb1 i think this is good to be added to the merge queue |
All three fail the main pass of every `Stateless tests (*, s3 storage, DBReplicated, sequential*)` run. On master this is hidden: the diagnostics rerun drops `--replicated-database`, the rerun passes, and llvm_coverage jobs report `flaky` as `OK` (340/340, 340/340 and 129/129 whitewashed rows in 7 days, 0 clean, 0 red). They are visible on the new lane of ClickHouse#122853: https://github.com/ClickHouse/ClickHouse/actions/runs/36622581675/job/109632143373 05229 and 05230 edit one replica's ZooKeeper nodes by the table's literal path. A Replicated database rewrites explicit engine arguments without macros to `<path>/auto_{shard}` and `<replica>auto_{replica}` (`_functional_tests_helper_database_replicated_replace_args_macros`), so the `rm`/`ls`/`create` calls print `No node` and every assertion reads 0. Every arm depends on that path, so both files get `no-replicated-database`, like the other tests that edit a table's nodes by a literal path. 05260 filters `system.query_log` with `log_comment LIKE '05260\_%'`, which also matches the test's default log comment. Under a Replicated database the DDL worker replays `CREATE TABLE t_dist_pd` as a secondary query carrying that comment, which adds one row. The filter now lists the three log comments the test sets, as `05104_distributed_ast_push_down_under_not` does. 04741_cancel_skip_index_marks_remote_read fails on the same lane because a lightweight `UPDATE` runs on every replica of a shard (ClickHouse#122285). ClickHouse#122393 fixes that, so the test is not touched here. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes: #122285
Related: #115287
DDLWorker::taskShouldBeExecutedOnLeadersendsALTER,OPTIMIZE,TRUNCATE, index DDL and, since #115287,DELETEto one replica per shard, but notUPDATE. A lightweightUPDATE ... ON CLUSTERon aReplicatedMergeTreetable therefore ran on every replica of a shard. Each run reads the patch part written by the previous run and writes a new one, so an assignment that isn't idempotent, such asSET v = v + 1, was applied once per replica.On a shard with two replicas, 100 became 102. A replica that was down when the entry was queued applied it again after it started. A plain
UPDATEin aReplicateddatabase with more than one shard goes through the sameDDLWorkercode and had the same problem.This PR adds
ASTUpdateQueryto that list. The existingsupportsReplicationcheck still makes the update run on every host for tables that don't replicate, such as plainMergeTree.All supported release branches (26.3, 26.7, 26.8, 26.9) are affected. On those branches,
DELETE ... ON CLUSTERwithlightweight_delete_mode = 'lightweight_update'is rewritten intoUPDATE ... ON CLUSTER, so the backport fixes that path too.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed lightweight
UPDATE ... ON CLUSTERonReplicatedMergeTreetables running on every replica of a shard instead of once per shard, which applied assignments such asSET v = v + 1once per replica. A plainUPDATEin aReplicateddatabase with more than one shard had the same problem.Workflow [PR]
Sync PR [sync-upstream/pr/122393]
Version info
26.10.1.1054-master(included in26.10and later)