Skip to content

Fix GLOBAL IN in projection WHERE with parallel replicas; restore coverage tests - #129863

Merged
alexey-milovidov merged 2 commits into
masterfrom
revert-129862-revert-129425-covgap/batch-20261104-003217
Nov 7, 2026
Merged

alexey-milovidov merged 2 commits into
masterfrom
revert-129862-revert-129425-covgap/batch-20261104-003217

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Reverts #129862 (restores the 7 coverage tests from #129425) and fixes the bug that made one of them fail.

05515_global_subquery_projection_where failed deterministically in the ParallelReplicas stateless jobs on master (report) with UNKNOWN_IDENTIFIER on _data_... in INSERT. This was a real server bug, not a test problem: with parallel replicas enabled, analysing the WHERE of a PROJECTION treated the source as remote, and GlobalSubqueriesVisitor replaced the right hand side of GLOBAL IN in the stored projection query in place with a temporary table that does not exist when the projection is calculated. When a table is created or attached, the stored projection is analysed with the global context, so enable_parallel_replicas in the default profile (as in that CI job) broke every such table regardless of session settings. ALTER TABLE ... ADD PROJECTION triggers it with only session settings.

A projection is always calculated locally, so parallel replicas are now disabled in the contexts of ProjectionDescription::getProjectionFromAST and calculateByQuery. Added 05565_projection_global_in_parallel_replicas, which reproduces the bug without the special CI config, and corrected the comments of 05515, which described the rewrite as intended behaviour.

Related: #129425
Related: #129862

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix INSERT failing with UNKNOWN_IDENTIFIER into a table whose PROJECTION has GLOBAL IN in WHERE, when the projection was created (or the table was loaded) with parallel replicas enabled.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/129863]

Version info

  • Merged into: 26.11.1.1598-master (included in 26.11 and later)

@clickhouse-gh

clickhouse-gh Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1cfc5bb]

Summary: ✅


AI Review

Summary

Reviewed #129863 at 1cfc5bb2e4da4025fc7ebed56bd50ca4550c6692. The change disables parallel replicas in projection analysis and calculation, preventing stored GLOBAL IN expressions from acquiring temporary-table references that break subsequent INSERT operations. It restores seven coverage tests and adds a focused regression test. No actionable findings.

Missing context / blind spots
  • ⚠️ Broader CI, including the parallel-replica configuration that originally exposed the bug, was pending during review. The Fast test report confirms both projection tests and the dictionary and totals tests pass. The S3 catalog, MySQL override, and XRay parser tests are skipped there; their applicable stateless jobs must supply runtime validation. No local build or tests were run.
Final Verdict

Status: ✅ Approve. No inline findings to post.

@clickhouse-gh clickhouse-gh Bot added pr-not-for-changelog This PR should not be mentioned in the changelog comp-testing Test content only (no production code). labels Nov 7, 2026
With parallel replicas enabled, analysing the `WHERE` of a `PROJECTION` treated the source as
remote, and `GlobalSubqueriesVisitor` replaced the right hand side of `GLOBAL IN` in the stored
projection query in place with a temporary table `_data_...`. Every later `INSERT` then failed
with `UNKNOWN_IDENTIFIER`. When the storage is created or attached, the projection is analysed
with the global context, so `enable_parallel_replicas` in the default profile broke any such
table regardless of session settings; `ALTER TABLE ... ADD PROJECTION` used the session settings.

A projection is always calculated locally, so disable parallel replicas in the contexts of
`getProjectionFromAST` and `calculateByQuery`.

This is why the test `05515_global_subquery_projection_where` from #129425 failed in the
`ParallelReplicas` jobs on master, which led to the revert in #129862.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=10e0db2ad742638c67d6321f6dcdae80cb4d5c2e&name_0=MasterCI
Related: #129425
Related: #129862
Related: #129863

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov alexey-milovidov changed the title Revert "Revert "Add 7 tests for coverage gaps in 5 components"" Fix GLOBAL IN in projection WHERE with parallel replicas; restore coverage tests Nov 7, 2026
@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default comp-projections Projections: precomputed layouts for accelerating queries (projection parts, maintenance). and removed pr-not-for-changelog This PR should not be mentioned in the changelog comp-testing Test content only (no production code). labels Nov 7, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 1cfc5bb2e with master 1e4565847 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 25a55661d; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 16 s compile time in total, 7 of them have a recent master baseline.

Job report

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 7, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

But we should check if parallel replicas work with projections at all. Because they should.

Merged via the queue into master with commit 6768ab4 Nov 7, 2026
195 checks passed
@alexey-milovidov
alexey-milovidov deleted the revert-129862-revert-129425-covgap/batch-20261104-003217 branch November 7, 2026 14:09
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 7, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Checked: parallel replicas do work with projections. The fix here only disables them while a projection is built (its definition analysed, its data calculated on INSERT/merge), not when a SELECT reads a projection.

  • On master, parallel_replicas_support_projection (default true since 25.8) with parallel_replicas_local_plan lets the projection optimizer run under parallel replicas. If some parts lack the projection, fallbackToLocalProjectionReading reads it on the initiator only; min-max and exact-count projections are also read only on the initiator, to avoid duplicates.
  • Local test: a server with test_cluster_one_shard_three_replicas_localhost, 4M rows in 4 parts, a normal projection (ORDER BY v), an aggregate projection, and a projection with GLOBAL IN in WHERE. Results are identical with and without parallel replicas, and system.query_log.projections shows the same projection chosen on the initiator and on the followers.
  • The read is coordinated across replicas: with send_logs_level = 'trace', DefaultCoordinator split the 15628 marks of the projection among all three replicas (6198 / 2048 / 7382). On fast queries (26-50 ms) the initiator sometimes finishes before the followers start, and they get cancelled after reading 0 rows; that is usual parallel replicas behaviour for small queries.

Unrelated to parallel replicas: a projection whose WHERE contains GLOBAL IN (subquery) is never selected, even when the query has the identical condition (query WHERE does not imply projection WHERE), also without parallel replicas. Such projections are only calculated and stored.

alexey-milovidov added a commit that referenced this pull request Nov 20, 2026
#129863 reverts the revert
#129862 (re-landing the
tests-only #129425) and also
carries a fix of its own, with a changelog entry. The nightly edit verifier
treats every revert of a change of this release as cancelling out and
required its bullet to be deleted (edit attempt 2/3 of
https://github.com/ClickHouse/ClickHouse/actions/runs/44660948255), so the
user-visible fix was lost. The 26.11 cycle is complete, so the nightly job
will not edit this section again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
lazerg pushed a commit to lazerg/ClickHouse that referenced this pull request Nov 22, 2026
…hange

A revert of a revert of this release was always treated as cancelling out,
so its own bullet had to go. `ClickHouse#129863` re-landed the tests-only `ClickHouse#129425`
(reverted by `ClickHouse#129862`) and also fixed `INSERT` into a table whose
`PROJECTION` has `GLOBAL IN` in `WHERE`, with a `Bug Fix` entry of its own.
The verifier rejected the edit that kept it ("Reverts of changes of this
release still have entries of their own"), and the retried edit dropped the
fix from the 26.11 changelog:
https://github.com/ClickHouse/ClickHouse/actions/runs/44660948255

Such a re-apply, one that arrived under a strict-retention category, is no
longer exempt from strict retention and not required to be deleted: its link
stays, as a bullet of its own or merged into the entry it brought back. The
prompt and the `edit-changelog` skill describe the case.

Related: ClickHouse#126190

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov pushed a commit that referenced this pull request Nov 22, 2026
The only conflict is in `ProjectionDescription::calculateByQuery`: master
also has the `enable_parallel_replicas` line of #129863 and the positional
arguments change of #126185 there, neither of which is on 26.10. Keep the
26.10 code and add only the `rewrite_in_to_join` line of #130143.

Also take the three lines of #129006 that materialize constant columns of
the calculated projection block. On 26.10 a projection column such as
`exists(SELECT ...)` is calculated as a `ColumnConst`, and once #130143
gives it the right name, writing the projection part fails with
`Bad cast from type DB::ColumnConst to DB::ColumnVector<char8_t>`
(the `t_subquery_normal` case of 05569). The rest of #129006 is not needed
on 26.10: its trigger, `optimize_constant_columns_after_filter`, does not
exist there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-projections Projections: precomputed layouts for accelerating queries (projection parts, maintenance). pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants