Repository navigation
Cherry pick #124477 to 26.8: Keep the population of a Replicated database DDL entry on the replica that executes it - #125068
Conversation
… that executes it Every replica of a `Replicated` database executes a `CREATE` entry and fills its own copy of the table, and such a `CREATE` always takes the non-atomic population (`shouldPopulateMaterializedViewAtomically` refuses the atomic path under a ZooKeeper metadata transaction). `fillTableIfNeeded` built that `INSERT ... SELECT` with the entry's own context, i.e. with the user's parallel-replicas settings, so `InterpreterInsertQuery` sent `INSERT INTO <table> SELECT ...` to every replica of `cluster_for_parallel_replicas` (`parallel_distributed_insert_select` defaults to 2) and the `SELECT` read through parallel replicas. A replica's rows landed in other replicas' tables (duplicated there, missing locally), or the remote INSERT failed with `UNKNOWN_TABLE` where the table did not exist yet; for `CREATE TABLE ... AS SELECT` the other replicas' DDL workers failed on the already renamed `_tmp_replace_*` table until they were recovered as lost replicas with an empty table. Under a ZooKeeper metadata transaction the population now uses a context copy with `parallel_distributed_insert_select = 0` and `enable_parallel_replicas = 0`, and both settings (plus the `allow_experimental_parallel_reading_from_replicas` alias) are removed from the copied `SELECT`, because its own `SETTINGS` are reapplied on top of the context; `removeSettingsFromQuery` also drops the `name = DEFAULT` form, which would restore the default 2. This is what the atomic `POPULATE` path already does. The single site covers `POPULATE`, `CREATE OR REPLACE ... POPULATE` and `CREATE TABLE ... AS SELECT`; the view's stored definition is unchanged, as only the clone is scrubbed. Reported by @ fm4v from 04494_atomic_populate_materialized_view_parallel_replicas in the DBReplicated lane, where every replica of the CI cluster points at the primary server. Test: 4 cases in `test_parallel_replicas_insert_select` (secondaries populating through the only live replica, the initiator populating before the other replicas created the view, CTAS into `Memory`, and the read side with different data per replica, with parallel replicas also enabled by the view's own `SETTINGS`), all failing on master and on 26.8.18.2. Closes #124446 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…late-parallel-replicas Keep the population of a Replicated database DDL entry on the replica that executes it
Resolve the cherry-pick of #124477 onto 26.8. The only conflict is context: on master the new settings list sits above fillTableIfNeeded, whose signature #117967 changed (published_table_name); 26.8 keeps its own signature (skip_target_insert_access_check), so the resolution adds only the lines #124477 adds and does not bring #117967 along. The test files merged cleanly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The only conflict is context. On master, the settings list #124477 adds in What I checked:
@fm4v, I have After that the robot merges this PR and opens the 26.8 backport PR itself. |
Original pull-request #124477
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Before you resolve anything
Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job