Skip to content

Forbid renaming the source of incremental refreshable views - #122826

Merged
SmitaRKulkarni merged 11 commits into
masterfrom
Inc_rmv_restrict
Nov 13, 2026
Merged

SmitaRKulkarni merged 11 commits into
masterfrom
Inc_rmv_restrict

Conversation

@SmitaRKulkarni

@SmitaRKulkarni SmitaRKulkarni commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

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):

Forbid renaming the source of incremental refreshable views closes ##120082


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

Version info

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

@clickhouse-gh

clickhouse-gh Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d8bf5ad]

Summary: ✅


AI Review

Summary

PR #122826, reviewed at d8bf5ad884d283ab0f05cbc1509b1ae19f3df865, prevents source replacement for APPEND INCREMENTAL refreshable materialized views through table and database DDL checks. The sequential replacement paths are now guarded, but two previously reported and deliberately deferred source-identity gaps still permit silent row loss. Both remain blockers below; no duplicate inline comments were posted.

PR Metadata

💡 Bug Fix is appropriate. The required changelog entry should describe the additional restrictions and their purpose. Suggested replacement:

Prevent silent row loss in APPEND INCREMENTAL refreshable materialized views by rejecting source table drops, renames, exchanges, and replacements, and source database drops and renames. Drop the dependent view before replacing its source.

Replace the malformed closes #https://... suffix with this relationship on its own line above the template:

Closes: https://github.com/ClickHouse/ClickHouse/issues/120082

Findings

❌ Blockers

  • Source protection disappears while a coordinated view is detached. src/Storages/StorageMaterializedView.cpp:1317 [dismissed by author -- https://github.com/Forbid renaming the source of incremental refreshable views #122826#discussion_r4272094668]. The author considers this by design; it remains real because detaching a view's Replicated database preserves its Keeper cursor while making the view unavailable to this lookup. After a successful refresh, detach that database, exchange its source in another database, and reattach the view's database: RefreshTask::shutdown preserves the coordination znode, and the next refresh reuses its cursor without checking source identity. Rows below the old cursor are silently skipped. Preserve protection from detached metadata or persist and validate the source identity before resuming a cursor.

  • Renaming an attached view temporarily removes its source protection. src/Storages/StorageMaterializedView.cpp:1312 [dismissed by author -- https://github.com/Forbid renaming the source of incremental refreshable views #122826#discussion_r4518617264]. The author deferred this to a follow-up; it remains real because InterpreterRenameQuery::executeToTables removes the view's referential dependencies at line 186 and restores them at line 200, while a concurrent source exchange holds different table guards. An exchange can pass this lookup during that interval and complete with the view's original cursor intact. The next refresh silently skips replacement-source rows below that cursor. Serialize source DDL with dependency rewrites, or validate source identity when reusing the cursor.

Tests
  • ⚠️ Add a focused coordinated view-database detach/source-exchange/reattach regression that refreshes before detaching and verifies that resuming cannot silently reuse the old source's cursor.
  • ⚠️ Add focused coverage for concurrent view renaming and source exchange. The new sequential view-renaming test cannot exercise the dependency-removal interval.
Missing context / blind spots
  • ⚠️ No local ClickHouse binary or configured build was available, so these lifecycle and concurrency traces were verified from source rather than executed. The fetched Praktika report lists no failures, but the added regressions do not cover the two remaining paths.
Final Verdict

❌ Block. Preserve source identity across view detachment and dependency rewrites, with focused regression coverage. A source-identity check before cursor reuse could address both gaps. Existing author-resolved threads remain closed; there are no new inline findings to batch.

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default comp-refreshable-materialized-view Refreshable materialized views: scheduled/periodic refresh, refresh state machine, refresh orches... labels Sep 29, 2026
@Michicosun Michicosun self-assigned this Oct 1, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing d8bf5ad88 with master 0d3338be0 (stripped binary size, per-symbol sizes and ThinLTO time; 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.

Slowest function optimization changes (ThinLTO)

Median per-function time ratio to the master baseline: programs/clickhouse ×0.64, programs/clickhouse-keeper ×0.66 (each binary is linked separately, on a different machine and with different build flags); deltas below are relative to it.

Binary Function Master PR Δ vs median
programs/clickhouse DB::registerFunctionConversion(DB::FunctionFactory&) 5.8 s 11.5 s +7.8 s (+211%)
programs/clickhouse _ZN6detail10static_forITk7is_enumN2DB23AttributeUnderlyingTypeEZNS1_29callOnDictionaryAttributeType… 3.3 s 7.5 s +5.4 s (+253%)
Compile time of recompiled translation units

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

Job report

@Michicosun Michicosun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Will it help with drop + create chain?

@SmitaRKulkarni
SmitaRKulkarni added this pull request to the merge queue Nov 13, 2026
Merged via the queue into master with commit 04f377b Nov 13, 2026
204 checks passed
@SmitaRKulkarni
SmitaRKulkarni deleted the Inc_rmv_restrict branch November 13, 2026 13:59
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 13, 2026
groeneai pushed a commit to groeneai/ClickHouse that referenced this pull request Nov 14, 2026
This reverts ClickHouse#122826 (merge commit 04f377b). The new check in `RENAME DATABASE` iterates all tables with the full iterator, which for a `DataLakeCatalog` database fetches the metadata of every catalog table and fails on any unreadable one.

Related: ClickHouse#131423
clickhouse-gh Bot pushed a commit that referenced this pull request Nov 20, 2026
Edited by the nightly changelog CI job following .claude/skills/edit-changelog/SKILL.md.

Changelog-revert: 127836 124816 Revert "Avoid building stream names and substreams cache keys for every block in MergeTreeReaderWide"
Changelog-revert: 128706 116083 Revert "Fit the insert pipeline and merges into a small server's memory"
Changelog-revert: 128760 128658 Revert "Prewarm macOS code signature verification of the clickhouse binary after linking"
Changelog-revert: 128947 127422 Revert "[GPU] `GDeflate` compression codec on the CPU"
Changelog-revert: 129099 128947 Revert "Revert "[GPU] `GDeflate` compression codec on the CPU""
Changelog-revert: 129310 127149 Revert "Mark a query as cancelled in the process list when its TCP client cancels it"
Changelog-revert: 129311 129310 Revert "Revert "Mark a query as cancelled in the process list when its TCP client cancels it""
Changelog-revert: 129862 129425 Revert "Add 7 tests for coverage gaps in 5 components"
Changelog-revert: 129863 129862 Fix `GLOBAL IN` in projection `WHERE` with parallel replicas; restore coverage tests
Changelog-revert: 129986 122871 Revert "Search long integer slices in 512-byte chunks on AArch64 in `hasAll` and `hasAny`"
Changelog-revert: 130046 129986 Revert "Revert "Search long integer slices in 512-byte chunks on AArch64 in `hasAll` and `hasAny`""
Changelog-revert: 130368 114729 Revert "CI: run the full test suite only when review threads are resolved"
Changelog-revert: 130509 130368 Revert "Revert "CI: run the full test suite only when review threads are resolved""
Changelog-revert: 130531 114923 Revert "Make a table read by a scalar subquery in a CONSTRAINT a loading dependency"
Changelog-revert: 131043 129464 Revert "Sync shared files changed by the private `AmberMap` PR"
Changelog-revert: 131045 130793 Revert "Fix wrong ORDER BY ... LIMIT results on Delta Lake tables with column mapping"
Changelog-revert: 131270 128764 Re-enable the adaptive aggregator for queries generated from PromQL
Changelog-revert: 131424 122826 Revert "Forbid renaming the source of incremental refreshable views"
Changelog-revert: 131562 131454 Revert "Build the symbol index in the background at server startup"
Changelog-revert: 131638 131562 Revert "Revert "Build the symbol index in the background at server startup""
Changelog-revert: 131691 130864 Revert "Use one source instead of N for parallel_inserts of AzureQueue/S3Queue"
Changelog-revert: 131765 119685 Revert "Enable `-mbranch-protection=pac-ret` on ARM"
Changelog-deleted-entry: 116083 [Performance Improvement] [section] * Reduce memory use for `INSERT` and background merges on servers with a few GiB of RAM. Write buffers, insert squashing, the `Parquet` reader and merge selection now scale with `max_server_memory_usage`, avoiding `MEMORY_LIMIT_EXCEEDED` during wide-table inserts and merges that repeatedly fail without reducing the part count. New `MergeTree` settings `max_memory_ratio_to_activate_adaptive_write_buffer` and `merge_memory_estimate_per_source_part_column` control adaptive write buffers and merge selection, respectively; set either to `0` to disable that adjustment. [#116083](#116083) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
Changelog-deleted-entry: 119685 [Build/Testing/Packaging Improvement] [raw] * Build the `C` and `C++` code of the ARM binaries with `-mbranch-protection=pac-ret`, which signs the return address so that overwriting it on the stack cannot redirect control flow; the AArch64 `.S` sources that key off `__ARM_FEATURE_PAC_DEFAULT` opt into the same signing. Sanitizer builds are excluded, because the sanitizer runtimes do not strip the signature when they unwind. [#119685](#119685) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
Changelog-deleted-entry: 122826 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * Forbid renaming the source of incremental refreshable views closes #[#120082](#120082). [#122826](#122826) ([Smita Kulkarni](https://github.com/SmitaRKulkarni)).
Changelog-deleted-entry: 128658 [NOT FOR CHANGELOG / INSIGNIFICANT] [raw] * Prewarm macOS code signature verification of the clickhouse binary after linking. [#128658](#128658) ([Azat Khuzhin](https://github.com/azat)).
Changelog-deleted-entry: 128764 [NOT FOR CHANGELOG / INSIGNIFICANT] [raw] * Disable the adaptive aggregator for queries generated from PromQL. [#128764](#128764) ([Vitaly Baranov](https://github.com/vitlibar)).
Changelog-deleted-entry: 129464 [NOT FOR CHANGELOG / INSIGNIFICANT] [raw] * Sync shared files changed by the private `AmberMap` PR. [#129464](#129464) ([Miсhael Stetsyuk](https://github.com/mstetsyuk)).
Changelog-deleted-entry: 130793 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * Fixed wrong results of `ORDER BY ... LIMIT` on a Delta Lake table with column mapping when a renamed column has the name that another column is stored under: the top-K dynamic filter (`use_top_k_dynamic_filtering`) compared the other column against the threshold and dropped rows of the true result. [#130793](#130793) ([Groene AI](https://github.com/groeneai)).
Changelog-deleted-entry: 130864 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * Use one source instead of N for parallel_inserts of AzureQueue/S3Queue. [#130864](#130864) ([Azat Khuzhin](https://github.com/azat)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-refreshable-materialized-view Refreshable materialized views: scheduled/periodic refresh, refresh state machine, refresh orches... 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.

3 participants