Skip to content

Cherry pick #124477 to 26.8: Keep the population of a Replicated database DDL entry on the replica that executes it - #125068

Merged
robot-clickhouse-ci-2 merged 3 commits into
backport/26.8/124477from
cherrypick/26.8/124477
Nov 3, 2026
Merged

robot-clickhouse-ci-2 merged 3 commits into
backport/26.8/124477from
cherrypick/26.8/124477

Conversation

@robot-ch-test-poll2

Copy link
Copy Markdown
Contributor

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-pick locally.
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:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

groeneai and others added 2 commits October 7, 2026 18:59
… 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
@robot-ch-test-poll2 robot-ch-test-poll2 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Oct 10, 2026
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]>
@groeneai

Copy link
Copy Markdown
Collaborator

The only conflict is context. On master, the settings list #124477 adds in InterpreterCreateQuery.cpp sits directly above fillTableIfNeeded, whose signature #117967 changed after the 26.8 cut (const String & published_table_name instead of 26.8's bool skip_target_insert_access_check). #117967 has no backport label, so this cherry-pick will not clear on its own. I kept 26.8's signature and added only #124477's lines, so nothing from #117967 comes along. The two test files merge cleanly. On 26.8 the patched code also populates WINDOW VIEW ... POPULATE (window views are removed on master); that backfill query is built fresh with no SETTINGS, so the change applies to it as is.

What I checked:

@fm4v, I have triage but not push on this repository, so I cannot update cherrypick/26.8/124477 myself. Applying it takes two commands:

git fetch https://github.com/groeneai/ClickHouse resolve-26.8-cherrypick-124477
git push origin FETCH_HEAD:cherrypick/26.8/124477

After that the robot merges this PR and opens the 26.8 backport PR itself.

@robot-ch-test-poll2

Copy link
Copy Markdown
Contributor Author

Dear @fm4v, @groeneai, this cherry-pick PR has not been updated for 3d0h6m48s. Please resolve the conflicts to backport #124477, or close this PR if the backport is no longer needed. This PR will be automatically closed after 7 days of inactivity.

@robot-clickhouse-ci-1

Copy link
Copy Markdown
Contributor

Dear @fm4v, @groeneai, this cherry-pick PR has not been updated for 7d0h4m32s. Closing automatically. If you still want to backport #124477, please resolve the conflicts and reopen this PR.

@robot-clickhouse-ci-2

Copy link
Copy Markdown
Contributor

Dear @fm4v, @groeneai, this PR is opened while #124477 was marked as backported. The pr-backports-created is removed, so the original PR can be processed again.

If the cherry-pick is not needed anymore, then just close this PR.

@robot-clickhouse-ci-2
robot-clickhouse-ci-2 merged commit 785d37d into backport/26.8/124477 Nov 3, 2026
1 check passed
@robot-clickhouse-ci-2
robot-clickhouse-ci-2 deleted the cherrypick/26.8/124477 branch November 3, 2026 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants