Skip to content

Validate the database engine of a non-APPEND refreshable materialized view on ATTACH and RESTORE - #111928

Merged
alexey-milovidov merged 6 commits into
ClickHouse:masterfrom
groeneai:fix/rmv-fresh-attach-engine-validation
Sep 26, 2026
Merged

alexey-milovidov merged 6 commits into
ClickHouse:masterfrom
groeneai:fix/rmv-fresh-attach-engine-validation

Conversation

@groeneai

@groeneai groeneai commented Jul 26, 2026 •

Copy link
Copy Markdown
Collaborator

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

Fixed a logical error (server abort in debug and sanitizer builds) when a non-APPEND refreshable materialized view was created in a non-Atomic/Replicated database via a full-definition ATTACH, or via a RESTORE of a view that had a UUID into such a database. CREATE already rejected this combination; ATTACH and RESTORE bypassed the check and produced a view with a Nil UUID whose refresh tripped a DatabaseCatalog::tryGetByUUID assertion in the Replicated-DDL parent-table lookup. Backups of views that never had a UUID stay restorable, and their refresh now fails cleanly instead of aborting.

Description

A non-APPEND refreshable materialized view is only supported in Atomic and Replicated databases: its refresh swaps the inner table through an atomic EXCHANGE, and it needs a real UUID for parent-table tracking when the target lives in a Replicated database. CREATE enforces this in validateMaterializedViewColumnsAndEngine, but that call is gated on mode <= LoadingStrictnessLevel::CREATE, so two fresh-definition paths bypassed it:

  • a full-definition ATTACH MATERIALIZED VIEW ... REFRESH ... TO ... (runs at LoadingStrictnessLevel::ATTACH), and
  • a RESTORE ... AS <other_db>.<view> that lands the view in a non-Atomic/Replicated database (runs at SECONDARY_CREATE with is_restore_from_backup).

In a Memory database the view gets a Nil StorageID UUID. When its refresh fires and issues CREATE OR REPLACE for the temp inner table into a Replicated-database target, the Nil UUID is written into DDLLogEntry.parent_table_uuid, and DatabaseReplicatedDDLWorker::checkParentTableExists(Nil) calls DatabaseCatalog::tryGetByUUID(Nil), hitting chassert(uuid != UUIDHelpers::Nil && ...). In release builds the assertion is compiled out and the refresh instead fails permanently with a misleading TABLE_IS_DROPPED "Parent table doesn't exist".

Fix:

  • Hoist the non-APPEND-RMV database-engine check out of validateMaterializedViewColumnsAndEngine into createTable, gated on is_fresh_definition = mode <= CREATE || (mode == ATTACH && !attach_short_syntax) || (is_restore_from_backup && create.has_uuid). This mirrors the existing is_fresh_definition predicate in registerStorageMergeTree.cpp: stored definitions (short ATTACH, ATTACH DATABASE, restart) were validated when introduced and keep loading; plain Replicated-DDL replay stays exempt (its database is Replicated anyway); fresh full-definition ATTACH is user input and is validated like CREATE. The exception text is unchanged.
  • Add a fail-close Nil guard in checkParentTableExists: a Nil UUID never identifies a table, so return false (mirrors the existing Nil guard in getRMVCoordinationInfo in the same file). This keeps metadata written by older binaries loadable and makes its refresh fail cleanly instead of aborting debug/sanitizer servers.

A RESTORE is only validated when the backed-up definition carried a UUID (create.has_uuid, which reflects the backup's own metadata: RESTORE overwrites uuid with a freshly generated one before the interpreter runs, but never has_uuid). A view that had a UUID lived in a database that holds UUIDs, so landing it in one that does not is the UUID-losing case that must be rejected. A backup of a view that never had a UUID (for example one moved to an Ordinary database by an earlier RENAME) is a definition that already lived without one: rejecting it would make such backups unrestorable on newer servers while the same metadata still loads on restart and on a short ATTACH, so it stays restorable under any name and the Nil guard keeps its refresh failing cleanly.

Found by BuzzHouse:

Both sighting PRs are unrelated to this code path (a datetime-function change and an unrelated change); the failure is a latent engine bug, not caused by either PR.


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

Version info

  • Merged into: 26.10.1.707-master (included in 26.10 and later)

groeneai and others added 2 commits July 25, 2026 19:31
…ESTORE

A non-APPEND refreshable materialized view is only supported in Atomic and
Replicated databases. CREATE enforced this in validateMaterializedViewColumnsAndEngine,
but the call is gated on mode <= CREATE, so a full-definition ATTACH (mode ATTACH) and
a RESTORE that remaps the view into another database (SECONDARY_CREATE with
is_restore_from_backup) bypassed the check. In a Memory database the view then got a
Nil StorageID UUID, and its refresh (CREATE OR REPLACE of the temp inner table into a
Replicated-db target) wrote the Nil into DDLLogEntry.parent_table_uuid, so
checkParentTableExists(Nil) -> DatabaseCatalog::tryGetByUUID(Nil) tripped
chassert(uuid != Nil && ...) (abort in debug/sanitizer; in release the refresh instead
failed permanently with TABLE_IS_DROPPED "Parent table doesn't exist").

Hoist the engine check out of validateMaterializedViewColumnsAndEngine into createTable,
gated on is_fresh_definition = mode <= CREATE || (mode == ATTACH && !attach_short_syntax)
|| is_restore_from_backup, mirroring the existing is_fresh_definition predicate in
registerStorageMergeTree.cpp. Stored definitions (short ATTACH, ATTACH DATABASE, restart)
and plain Replicated-DDL replay stay exempt; fresh full-definition ATTACH and
RESTORE-with-remap are validated like CREATE. Also add a fail-close Nil guard in
checkParentTableExists (return false, mirroring the existing guard in
getRMVCoordinationInfo) so metadata written by older binaries loads and its refresh
fails cleanly instead of aborting.

Found by BuzzHouse (arm_asan_ubsan on PR ClickHouse#111370, amd_msan on PR ClickHouse#109454; both
unrelated to this code path).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The test proved that a fresh full-definition ATTACH and a RESTORE-with-remap are
rejected, but neither of the compatibility promises the fix makes was asserted, so
removing either guard left the whole suite green.

A cross-engine RENAME reaches the pre-fix state without going through
InterpreterCreateQuery: DatabaseOnDisk::renameTable swaps the UUID away when moving
from Atomic to Ordinary and installs the definition with the target database's own
createTable. That yields a stored, Nil-UUID, non-APPEND refreshable view on a fixed
binary, so the test can now assert that such a definition still loads via short ATTACH
and that its refresh is refused with TABLE_IS_DROPPED while the server stays up.
The Nil UUID itself is asserted too, because the coverage is meaningless if the RENAME
ever stops clearing it.

The view is created with EMPTY so the only refresh in the test is the explicit
SYSTEM REFRESH VIEW after the RENAME, and its target is a plain MergeTree table inside
the Replicated database, which is what routes the refresh's CREATE OR REPLACE through
the Replicated DDL log and into the parent-table lookup.

Verified by patching out each guard in turn: without the attach_short_syntax exemption
the stored definition no longer attaches, and without the Nil guard the server aborts
on the refresh with the original assertion. Also drop the tables the test leaves behind.
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review - adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 2 findings across 2 rounds), plus 4 findings from my own cold review of the same diff.

# Sev Finding Verdict Evidence / action
1 ⚠️ The test exercises neither legacy-definition safeguard, so it stays green if stored definitions stop loading or the Nil-UUID guard is removed (04628_..._engine_validation.sh) AGREE - fixed @ 30f07ca Added a legacy fixture (Atomic to Ordinary RENAME, which clears the UUID and installs the stored definition through the target database's own createTable) plus legacy_short_attach_ok, legacy_refresh_refused, server_alive. Both guards were then patched out one at a time: removing && !create.attach_short_syntax loses two reference lines; removing the Nil guard aborts the server with the byte-identical assertion this PR fixes. The suite now regression-guards the reported failure itself, not only the admission check.
2 ⚠️ A cross-engine RENAME can still introduce a fresh non-APPEND refreshable MV into an unsupported database (DatabaseOnDisk::renameTable) DISAGREE The mechanism is real and is exactly the fixture used above, but it is not a defect this PR leaves open. The abort is closed on that path: the fail-close Nil guard sits at the only consumer that asserted, and the kill-test above proves the renamed view aborts without the guard and fails cleanly (REFRESH_FAILED / Code 218 TABLE_IS_DROPPED, server alive) with it. Every other Nil-reachable consumer was already Nil-safe (getRMVCoordinationInfo, shouldSkipCreatingRMVTempTable). The RENAME admission gap is pre-existing (renameTable never applied this validation, and this PR does not touch DatabaseOnDisk.cpp), and Atomic/Ordinary moves are deliberately supported, so rejecting them would be a backward-incompatible change needing its own changelog category and maintainer sign-off rather than a change to this fix.
3 💡 The test left tables behind in the runner-created database AGREE - fixed @ 30f07ca All three test databases and the seven tables/views are dropped at the end.
4 💡 2>/dev/null on the APPEND ATTACH control line hides a genuine failure's message DISAGREE It hides the message, not the failure: a failed ATTACH drops append_allowed from stdout and the reference diff fails. Surfacing stderr instead would fail the test on the expected full-definition-ATTACH warning, since a non-empty stderr is itself a failure reason in clickhouse-test.
5 💡 One view is created without EMPTY, so its first refresh can overlap the following BACKUP DISAGREE BACKUP TABLE of a view captures only the view's own metadata, the 50-run randomized sweep is green, and a failed BACKUP would drop restore_rejected (a loud failure, never a silent pass). Noted for a future touch of this test.
6 💡 no-ordinary-database is partly redundant with atomic-database DISAGREE atomic-database already skips when the database engine is not Atomic; the residual effect is skipping on servers where allow_deprecated_database_ordinary defaults to 1. The sibling test 04218_refreshable_mv_secondary_create.sh carries the same tag pair.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. On pristine HEAD, a debug server aborts within ~1s of: CREATE DATABASE m ENGINE=Memory; CREATE DATABASE r ENGINE=Replicated(...); CREATE TABLE r.t (c0 Int32) ENGINE=MergeTree ORDER BY c0; ATTACH MATERIALIZED VIEW m.v REFRESH AFTER 1 SECOND TO r.t (c0 Int32) AS SELECT 1 AS c0; The abort is the exact CI assertion 'uuid != UUIDHelpers::Nil && getFirstLevelIdx(uuid) < uuid_map.size()' with the checkParentTableExists frame. The regression test also reproduces the same assertion on demand once the checkParentTableExists Nil guard is patched out.
b Root cause explained? The non-APPEND-RMV database-engine check runs only for mode <= CREATE. A full-definition ATTACH (mode ATTACH) and a RESTORE-with-remap (mode SECONDARY_CREATE, is_restore_from_backup) skip it, so the view is created in a Memory db with a Nil StorageID UUID. Its refresh issues CREATE OR REPLACE for the temp inner table into the Replicated-db target; the Nil UUID lands in DDLLogEntry.parent_table_uuid; checkParentTableExists(Nil) -> tryGetByUUID(Nil) trips the chassert.
c Fix matches root cause? Yes. The primary fix restores the CREATE-time contract for all FRESH definition paths (hoisted engine check gated on is_fresh_definition), so the invalid view can no longer be created. The secondary fail-close Nil guard in checkParentTableExists covers metadata already persisted by older binaries. No symptom band-aid (no widened bounds, no no-random-*).
d Test intent preserved / new tests added? New regression test 04628_rmv_non_append_fresh_definition_engine_validation.sh: CREATE reject, full-def ATTACH reject (the crash query), APPEND allowed (control), Atomic non-APPEND allowed (over-block control), RESTORE-remap-into-Memory reject, plus both legacy-compatibility behaviors - a stored Nil-UUID non-APPEND RMV (produced by an Atomic to Ordinary cross-engine RENAME, which installs the definition without InterpreterCreateQuery) still loads via short ATTACH, and its refresh is refused cleanly with TABLE_IS_DROPPED while the server stays up. No existing test weakened.
e Both directions demonstrated? Yes, per guard. Crash reproduces on pristine HEAD (build id 0eead38f); with the fix the ATTACH is rejected with INCORRECT_QUERY and the server stays up (build id d0b5337c). New test PASSES on fixed / FAILS on pristine (missing attach_rejected+restore_rejected). Two kill-tests: removing && !create.attach_short_syntax breaks the stored-definition load (test fails); removing the checkParentTableExists Nil guard aborts the server with the original assertion (test fails). 50/50 randomized runs pass.
f Fix is general across code paths? Yes. Enumerated every fresh-definition entry point: CREATE (already validated), full-def ATTACH (fixed), RESTORE-with-remap (fixed), short-syntax ATTACH / ATTACH DATABASE / restart (exempt, replay validated definitions; covered by the Nil backstop), Replicated-DDL replay (exempt, its db is Replicated). The only setParentTable caller is Nil-safe by the same fix; both checkParentTableExists call sites (initiator + replay) now Nil-guarded.
g Fix generalizes across inputs? Yes for the relevant axis: the check keys on the view's database engine (Atomic/Replicated allowed; everything else rejected) and the APPEND flag (APPEND exempt in any engine, verified). No datatype/wrapper axis applies (this is a DDL admission check, not a data path).
h Backward compatible? Yes. No wire/format/settings change (no SettingsChangesHistory.cpp needed). Restoring a backup to its original Atomic/Replicated layout still works (verified). The only newly-rejected inputs are fresh full-def ATTACH / RESTORE-remap of a non-APPEND RMV into an unsupported engine, the same combination CREATE already refuses. Views persisted by older binaries still LOAD (attach_short_syntax exempt) and now fail their refresh cleanly instead of aborting.
i Invariants and contracts preserved? Yes. Invariant restored: a non-APPEND RMV exists only in an Atomic/Replicated database (hence always has a real UUID; hence parent_table_uuid, when set, is non-Nil). checkParentTableExists postcondition unchanged for valid UUIDs; Nil now returns false (parent absent) fail-close, matching the existing Nil guard in getRMVCoordinationInfo and release-build semantics. Exception messages byte-identical.

Session id: cron:clickhouse-impl-slot-6:20260725-232000

@groeneai

groeneai commented Jul 26, 2026 •

Copy link
Copy Markdown
Collaborator Author

cc @tuanpach @al13n321 - could you review this? A non-APPEND refreshable materialized view was only engine-validated on CREATE, so a full-definition ATTACH and a RESTORE that remaps the view into a Memory/Ordinary database produced a Nil-UUID view whose refresh hit a DatabaseCatalog::tryGetByUUID assertion in the Replicated-DDL parent-table lookup; the check now runs on every fresh definition, and checkParentTableExists fail-closes on a Nil UUID so pre-existing stored definitions keep loading and refuse their refresh cleanly.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jul 26, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c1508c6]

Summary: ✅


AI Review

Summary

This PR moves the non-APPEND refreshable-materialized-view database-engine guard onto full-definition ATTACH and the relevant RESTORE path, adds a Nil-UUID backstop in DatabaseReplicatedWorker, and expands the stateless regression test. The original assertion path is fixed, but one correctness hole remains in the restore compatibility carve-out, so I would not merge it as-is.

Findings

❌ Blockers

  • [dismissed by author -- https://github.com/Validate the database engine of a non-APPEND refreshable materialized view on ATTACH and RESTORE #111928#discussion_r3651903225] [src/Interpreters/InterpreterCreateQuery.cpp:2093-2098] is_uuid_losing_restore treats every UUID-less backup as harmless legacy replay, but RESTORE always generates a fresh table UUID before this interpreter runs (src/Backups/RestorerFromBackup.cpp:866-868) and StorageMaterializedView still skips its non-replicated-target guard for SECONDARY_CREATE (src/Storages/StorageMaterializedView.cpp:331-359). A backup created after moving a valid non-APPEND RMV from Atomic to Ordinary therefore restores into a Replicated database with a real view UUID, coordinated refresh, and a non-replicated target table even though plain CREATE rejects that combination because refresh can replace peer replicas' targets with empty tables. The author is right that this gap also exists on current master, but this PR now codifies create.has_uuid as the compatibility discriminator for restored legacy definitions, so it still preserves the unsafe RESTORE ... AS rep_db.v case instead of closing it.
  • Suggested fix: keep the compatibility exemption limited to replay into non-UUID databases, or rerun the StorageMaterializedView target-engine validation on restore when the destination database is Replicated.
Tests
  • The new stateless test only restores the UUID-less legacy view back into Ordinary, so it never exercises the RESTORE ... AS <replicated_db>.v shape above and would stay green if that replicated-destination hole regresses.
Final Verdict

Changes requested.

LLVM Coverage Report

Measured on commit c1508c6.

Metric Baseline Current Δ
Lines 89.10% 89.10% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 81.50% 81.50% +0.00%

Changed lines: Changed C/C++ lines covered: 22/24 (91.67%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jul 26, 2026
groeneai and others added 3 commits July 26, 2026 05:15
The fresh-definition gate treated every RESTORE as fresh input, because
DatabaseWithOwnTablesBase::createTableRestoredFromBackup unconditionally sets
is_restore_from_backup before running the interpreter. A restore therefore could
not be told apart from a remap, so a backup of a non-APPEND refreshable
materialized view that already lived in a Memory or Ordinary database stopped
being restorable into the very database it was taken from: the restore threw
INCORRECT_QUERY even though the same metadata still loads on restart and on a
short ATTACH, and its refresh already fails closed through the Nil guard in
checkParentTableExists.

Such a definition carries no UUID in the backup. RESTORE overwrites the create
query's uuid with a freshly generated one before the interpreter runs, but it
never touches has_uuid, which still reflects what the backup stored. A restore
is therefore only a remap when has_uuid is set: the view lived in a database
that holds UUIDs, so landing it in one that does not is the case that must be
rejected. A UUID-less backup is a definition that already lived without a UUID
and stays restorable.

The regression test gains a same-database restore of the UUID-less definition it
already builds via a cross-engine RENAME. Removing the has_uuid condition loses
that line, and the two pre-existing kill-tests still bite: dropping
!create.attach_short_syntax loses three lines, and dropping the Nil guard aborts
the server with the original assertion.

Co-Authored-By: Claude Fable 5 <[email protected]>
The restore renaming map is applied before the interpreter runs and nothing
records that a rename happened, so a UUID-less definition restored under another
name is indistinguishable from one restored in place. Both are accepted, which is
the intent: there is no UUID to lose either way, and the resulting view is
harmless because the Nil guard in checkParentTableExists refuses its refresh
instead of aborting.

Say so explicitly rather than leaving it implied. The predicate is renamed to
is_uuid_losing_restore, which is what it actually tests, and the test now
restores the UUID-less definition under a second name and asserts both that the
restore succeeds and that the copy's refresh is refused cleanly with the server
still up.

Co-Authored-By: Claude Fable 5 <[email protected]>
The rationale it spelled out belongs in the commit messages and the PR
description, not next to the predicate. Keep only what a reader needs at this
line: which definitions are validated, and why has_uuid is the right signal.

Co-Authored-By: Claude Fable 5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

Confirmed and fixed in 467fc2c.

DatabaseWithOwnTablesBase::createTableRestoredFromBackup does set is_restore_from_backup unconditionally, and the regression was real: a backup of a non-APPEND refreshable MV taken from an Ordinary database failed to restore into that same database with INCORRECT_QUERY, while the identical metadata still loaded on restart and on a short ATTACH.

The predicate now keys on create.has_uuid instead of the bare restore flag. That flag is the backup's own metadata: RESTORE overwrites create.uuid with a freshly generated one before the interpreter runs (RestorerFromBackup::generateUUIDForTable), but never has_uuid. So it separates a view that had a UUID, which is about to lose it here, from one that never had one. Only the first case is rejected.

Two rows were added to 04628_rmv_non_append_fresh_definition_engine_validation: legacy_restore_ok for the same-database restore, and legacy_restore_as_ok plus legacy_restore_as_refresh_refused for a restore under another name, since the renaming map is applied before the interpreter and a rename is not distinguishable there. Accepting it is intended: there is no UUID to lose either way, and the Nil guard refuses the resulting view's refresh with REFRESH_FAILED / Parent table doesn't exist instead of aborting, which I verified with the server still answering afterwards.

Removing the has_uuid condition drops all three new rows, so the compatibility promise is now covered. The two earlier kill-tests still bite: dropping !create.attach_short_syntax loses five rows, and dropping the Nil guard aborts the server with the original assertion.

/// were already validated, and rejecting them would make existing metadata unloadable.
/// `has_uuid` is the backup's own metadata, not the UUID this restore generated, so it tells a
/// view that had a UUID (about to lose it here) from one that never had one.
const bool is_uuid_losing_restore = is_restore_from_backup && create.has_uuid;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

create.has_uuid is too weak a proxy for "this restore is just replaying old metadata". A backup taken after moving a valid non-APPEND RMV from Atomic to Ordinary has has_uuid == false, so RESTORE ... AS rep_db.v now skips this gate. But in a Replicated destination assertOrSetUUID regenerates a real UUID (InterpreterCreateQuery.cpp:1572), so this is no longer replaying the old Nil-UUID definition: StorageMaterializedView switches to coordinated refresh, while its CREATE-time guard against a non-replicated target only runs for mode < SECONDARY_CREATE (StorageMaterializedView.cpp:242-246). That lets restore create the exact combination CREATE refuses because each refresh can replace the target on other replicas with empty tables. The compatibility carve-out needs to stay limited to replaying UUID-less metadata into non-UUID databases, or restore needs to rerun the target-engine validation for Replicated destinations.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The mechanism is real, but it is pre-existing master behavior that this PR cannot influence, so I am not changing the predicate. Checked on the PR-head binary (server buildId() verified against readelf).

The gate only throws when the destination engine is neither Atomic nor Replicated:

if (database && database->getEngineName() != "Atomic" && database->getEngineName() != "Replicated")
    throw Exception(ErrorCodes::INCORRECT_QUERY, ...);

is_uuid_losing_restore decides whether that block is entered, not what it does. For a Replicated destination the condition is false by construction, so has_uuid cannot change the outcome. Restoring into a Replicated database, same db, both directions of the flag:

Backup UUID clause in backup metadata has_uuid gate entered RESTORE ... AS rep_db.v
cross-engine RENAME (Nil UUID) absent false no RESTORED
plain Atomic view UUID '3bc56a82-...' true yes RESTORED

The second row enters the gate and still succeeds, so has_uuid is not the discriminator the comment assumes. Both restored views get a real UUID in the destination, which matches assertOrSetUUID and is unchanged by this PR.

The two mechanics cited are untouched here:

  • StorageMaterializedView.cpp:218 mode < LoadingStrictnessLevel::SECONDARY_CREATE && !fixed_uuid is byte-identical at the base commit, and this PR does not modify StorageMaterializedView.cpp.
  • mode = getLoadingStrictnessLevel(..., is_secondary_query || is_restore_from_backup) is also pre-existing, so RESTORE has always been SECONDARY_CREATE and that target-engine guard has always been skipped on restore. At the base commit the engine check ran only under mode <= CREATE, so it never ran on a restore either.

Restore-into-Replicated therefore behaves exactly as it does on master. Plain CREATE still refuses the combination (Code: 36, "refreshable materialized view, no APPEND, replicated database, non-replicated table"), the server stays up, and no assertion fires.

The residual gap in master is genuine and I reproduced it, but constraining RESTORE for a pre-existing behavior is a backward-incompatible change that needs a maintainer decision and its own changelog entry, and it is a second concern in a single-root-cause PR. I am tracking it separately instead of folding it in here.

@clickhouse-gh

clickhouse-gh Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.30% 86.20% -0.10%
Functions 92.00% 91.90% -0.10%
Branches 78.40% 78.20% -0.20%

Changed lines: Changed C/C++ lines covered: 24/26 (92.31%) · Uncovered code

Full report · Diff report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 467fc2c

Every failure below has an owner: a fixing PR (mine or external). Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stress test (amd_debug) / Logical error: Inconsistent KeyCondition behavior (STID 5182-2f27) trunk debug-only monotonicity canary (#90461). Server log confirms the wide-cast leading-key shape: Participating conditions: (_CAST(column 0) in ['5', '5']), (column 1 in [945, 945]) on t_big #109023 (mine, open)
Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) / Got read request from replica A for unknown stream B (STID 5217-5b3d) + Server died trunk parallel-replicas coordinator bug (issue #110518). Single abort in the job log: unknown stream test_2zwja956.'.inner_id.08fe9dd3-...'; Server died is its collateral #111689 (mine, open)
Stateless tests (amd_llvm_coverage, old analyzer, s3 storage, DBReplicated, WasmEdge, parallel, 2/3) / Logical error '!part.empty()' (STID 2735-47bf) + Server died report label is a misattribution. The log holds exactly two Logical error strings: line 183181 is an SQL comment echoed from 04367_lambda_arg_backquoted_dot_no_logical_error, and the single genuine abort at line 209762 is Arguments of 'multiply' have incorrect data types: 'n' of type 'Int256', '0.123' of type 'Float64' from 03915_exchange_tables_race #110048 (external, open) root cause, #109747 (mine, open) abort avoidance; report naming fixed by #111708 (mine, open)
CH Inc sync - CH Inc sync (private, not actionable by me)

None is PR-caused: this PR touches InterpreterCreateQuery, DatabaseReplicatedWorker and the new 04628_rmv_non_append_fresh_definition_engine_validation test, which passes everywhere it ran, including 50/50 in each of the four flaky checks (amd_debug, amd_asan_ubsan, amd_msan, amd_tsan). The three aborts are in unrelated subsystems (MergeTree key analysis, parallel-replicas coordination, EXCHANGE TABLES type re-resolution).

Session id: cron:our-pr-ci-monitor:20260726-103000

Re-threads the fix onto master's current shape.

`ASTRefreshStrategy::append` became the `RefreshMode` enum, so the non-APPEND
test is now `!isAppend()`, i.e. `mode == RefreshMode::Replace`. That selects the
same views the old `!append` did: APPEND split into APPEND and APPEND
INCREMENTAL, and `isAppend()` reports both.

Master has since added `isFreshTableDefinition(level, attach_short_syntax)` in
Databases/LoadingStrictnessLevel.h, holding exactly the predicate this branch
open-coded, with four call sites already using it. The hoisted check now calls
it and keeps only the restore-specific term this fix adds, so the branch no
longer carries a second copy of that definition.

Both halves of the fix are still needed on master: `checkParentTableExists`
still calls `tryGetByUUID` with an unchecked UUID, and the refreshable-view
database-engine check still runs only under `mode <= CREATE`.

Co-Authored-By: Claude Opus 5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-refreshable-materialized-view Refreshable materialized views: scheduled/periodic refresh, refresh state machine, refresh orches... and removed comp-materialized-view Materialized views: insert-triggered MV pipeline, insert dependencies, deduplication. labels Sep 14, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing c1508c670 with master 7f4f87559 (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.

Compile time of recompiled translation units

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

Job report

@alexey-milovidov alexey-milovidov added the blocker This issue / pr blocks a new release label Sep 21, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 36 queries analysed

This PR changes only refreshable materialized view creation/attach/restore validation and a Nil-UUID guard in Replicated-DDL parent-table lookup — none of which runs during a ClickBench SELECT. The single flagged query (ClickBench Q28, -5.2%) already landed as not_sure because the two tests disagreed and the measurements were noisy, and it exercises no code this diff touches, so treat it as run-to-run variance rather than a PR effect. No real performance impact is expected from this change.

clickbench

⚠️ 1 inconclusive

Flagged queries (1 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 28 not_sure 1105 1048 -5.2% 0.0116 This PR only touches refreshable-MV creation/validation and Replicated-DDL parent lookup; it cannot reach a ClickBench Q28 SELECT hot path, so the -5.2% is run-to-run variance. The two tests disagree and the measurements were noisy.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: add4bebe-741e-47ff-a558-8b5fcad318ac
  • MIRAI run: cfa279fe-aab3-4a22-9bcb-540d7ea48e17
  • PR check IDs:
    • clickbench_1102113_1789959589
    • clickbench_1102119_1789959589
    • clickbench_1102129_1789959589
    • tpch_adapted_1_official_1102136_1789959589
    • tpch_adapted_1_official_1102147_1789959589
    • tpch_adapted_1_official_1102184_1789959589

@alexey-milovidov alexey-milovidov self-assigned this Sep 25, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 25, 2026
Merged via the queue into ClickHouse:master with commit 3d9e5ef Sep 26, 2026
176 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocker This issue / pr blocks a new release can be tested Allows running workflows for external contributors comp-refreshable-materialized-view Refreshable materialized views: scheduled/periodic refresh, refresh state machine, refresh orches... groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding 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