Skip to content

Fix Metadata is not initialized on DELETE FROM for data lakes - #104917

Merged
alexey-milovidov merged 10 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-supports-delete-datalake-104891
May 31, 2026
Merged

alexey-milovidov merged 10 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-supports-delete-datalake-104891

Conversation

@groeneai

@groeneai groeneai commented May 14, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes a logical error sibling to #104711 that the parent fix PR #104738 (lazy-init for OPTIMIZE / ALTER) did not cover.

InterpreterDeleteQuery::execute calls table->supportsDelete() before table->checkMutationIsPossible() in the DELETE FROM ... WHERE ... path. For a freshly-attached Iceberg / DeltaLake / Hudi table whose current_metadata has not yet been loaded (e.g. after a server restart when the previous load failed and was swallowed by the lazy-init catch in StorageObjectStorage's constructor — which is the situation reproduced by the issue), DataLakeConfiguration::supportsDelete() calls assertInitialized() and raised LOGICAL_ERROR: Metadata is not initialized. Fatal in debug / sanitizer builds.

The merged PR #104738 moved the lazy-init into DataLakeConfiguration for optimize, alter, checkMutationIsPossible, checkAlterIsPossible. But all four are reached after supportsDelete() in the DELETE FROM path, so they never get a chance to run.

InsertDependenciesBuilder calls supportsParallelInsert() while building the INSERT pipeline. That has the same shape — clickgap[bot] flagged both in #104891 — so it gets the same treatment.

Fix

Override supportsDelete() and supportsParallelInsert() on StorageObjectStorage (matching the existing pattern of supportedPrewhereColumns() and getColumnSizes() in the same file) and call lazyInitializeIfNeeded() on data lake configurations before delegating. A regular user-facing exception is raised instead of a logical error, and the server keeps running.

Regression test

04238_iceberg_supports_delete_metadata_not_initialized_104891.sh is a sibling of 04230 (added by the parent PR for the OPTIMIZE / ALTER paths). It triggers the same corrupt-metadata-on-disk state (iceberg_metadata_compression_method = 'deflate' + invalid output_format_compression_level = 11 on INSERT), does DETACH ... SYNC + ATTACH, then immediately runs DELETE FROM ... WHERE ... with no preceding OPTIMIZE / ALTER so the supportsDelete() lazy-init is exercised against uninitialized metadata. Without the fix the server raises a fatal logical error; with the fix it raises INCORRECT_DATA for the corrupted metadata file and stays alive.

Verified locally on debug build (groeneai/fix-supports-delete-datalake-104891 at 07049d0):

  • Without fix: Fatal Logical error: 'Metadata is not initialized' at DataLakeConfiguration.h:404 → server SIGABRT.
  • With fix: Code: 117. DB::Exception: ... INCORRECT_DATA → server keeps running, test 10/10 passes.

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 Logical error: 'Metadata is not initialized' raised by DELETE FROM on a freshly-attached Iceberg, DeltaLake, or Hudi table whose metadata file is corrupted or unloadable. A regular user-facing exception is reported instead, and the server keeps running. Closes #104891.

Documentation entry for user-facing changes

Closes #104891
Related: #104711, #104738

🤖 Generated with Claude Code


Note

Medium Risk
Touches StorageObjectStorage capability checks used by DELETE/INSERT planning for Iceberg/DeltaLake/Hudi, which can affect query execution paths; changes are small and covered by new regression tests.

Overview
Prevents crashes on freshly attached data lake tables with unloadable/corrupted metadata by forcing lazyInitializeIfNeeded() before delegating to configuration->supportsDelete() and configuration->supportsParallelInsert().

Adds stateless regression tests (04238, 04240) that reproduce the uninitialized-metadata scenario (including an MV dependent-sink INSERT) and assert operations fail with user-facing errors rather than Logical error, and that the server remains alive.

Reviewed by Cursor Bugbot for commit ef285ca. Bugbot is set up for automated code reviews on this repo. Configure here.

Version info

  • Merged into: 26.6.1.286
  • Backported to: 26.5.3.12, 26.4.5.13

`InterpreterDeleteQuery::execute` calls `table->supportsDelete()` BEFORE
`table->checkMutationIsPossible()`. For a freshly-attached `Iceberg` /
`DeltaLake` / `Hudi` table whose `current_metadata` has not been loaded
(typical after server restart when the previous metadata load failed and
was swallowed by the lazy-init catch in `StorageObjectStorage`'s
constructor), `DataLakeConfiguration::supportsDelete()` raised
`LOGICAL_ERROR: Metadata is not initialized` from `assertInitialized()`,
fatal in debug / sanitizer builds.

This is the sibling case of the issue fixed for `OPTIMIZE` / `ALTER` by
PR ClickHouse#104738 (which moved lazy-init into `DataLakeConfiguration` for
`optimize`, `alter`, `checkMutationIsPossible`, `checkAlterIsPossible`).
The `supportsDelete()` call site is reached before any of those four
methods in the `DELETE FROM` path, so the merged fix never runs.

`InsertDependenciesBuilder` reaches `supportsParallelInsert()` with the
same shape during `INSERT` pipeline construction, so apply the same
treatment to it.

Override `supportsDelete()` and `supportsParallelInsert()` on
`StorageObjectStorage` (matching the existing pattern of
`supportedPrewhereColumns()` and `getColumnSizes()` in the same file)
and call `lazyInitializeIfNeeded()` on data lake configurations before
delegating. A regular user-facing exception is raised instead of a
logical error, and the server keeps running.

New regression test `04238_iceberg_supports_delete_metadata_not_initialized_104891`
exercises the `DELETE FROM` path right after `DETACH+ATTACH` with no
preceding `OPTIMIZE` / `ALTER`, so the `supportsDelete()` lazy-init is
not masked by initialization from another code path.

Closes ClickHouse#104891
Related: ClickHouse#104711, ClickHouse#104738

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate (TASK.md Phase 4 step 9):

(a) Deterministic repro? YES. Setup: CREATE TABLE t (c0 Int32) ENGINE = IcebergLocal('...') SETTINGS iceberg_metadata_compression_method = 'deflate' + INSERT ... SETTINGS allow_insert_into_iceberg=1, output_format_compression_level=11 (corrupts on-disk metadata) + DETACH TABLE t SYNC + ATTACH TABLE t + DELETE FROM t WHERE c0 = 0 SETTINGS allow_insert_into_iceberg=1. Reliably triggers Fatal: Logical error: 'Metadata is not initialized' in DataLakeConfiguration<StorageLocalConfiguration, IcebergMetadata>::supportsDelete() at DataLakeConfiguration.h:404 (the assertInitialized() call).

(b) Root cause explained? YES. InterpreterDeleteQuery::execute() (line 92) calls table->supportsDelete() BEFORE table->checkMutationIsPossible() (line 103). For a freshly-attached data lake table with current_metadata == nullptr (corrupted metadata swallowed by lazy-init catch in StorageObjectStorage's constructor), DataLakeConfiguration::supportsDelete() calls assertInitialized() and throws LOGICAL_ERROR. The lazy-init that #104738 added to the four checkMutation / checkAlter / optimize / alter methods is reached too late — supportsDelete() already failed. supportsParallelInsert() has the same shape — InsertDependenciesBuilder.cpp:768 calls it during INSERT pipeline construction.

(c) Fix matches root cause? YES. StorageObjectStorage::supportsDelete() and supportsParallelInsert() now call configuration->lazyInitializeIfNeeded(object_storage, CurrentThread::tryGetQueryContext()) for data lake configurations BEFORE delegating. The lazy init either populates current_metadata (success) or raises a regular exception (e.g. INCORRECT_DATA for corrupt metadata). Matches the existing pattern of supportedPrewhereColumns() / getColumnSizes() in the same file. NOT a defensive if (!ptr) return false; band-aid — actually drives the underlying metadata load.

(d) Test intent preserved? / New tests added? YES — added new 04238_iceberg_supports_delete_metadata_not_initialized_104891.sh sibling of 04230 (PR #104738's regression test). New test starts with DETACH+ATTACH and immediately runs DELETE FROM so the supportsDelete() lazy-init is exercised against uninitialized metadata (no preceding OPTIMIZE / ALTER to mask it). Existing 04230 still passes (no regression).

(e) Both directions demonstrated? YES on debug build:

  • WITHOUT fix (master c2f4d729254): Fatal Logical error: 'Metadata is not initialized' at DataLakeConfiguration.h:404, server SIGABRT.
  • WITH fix (branch groeneai/fix-supports-delete-datalake-104891 at 07049d0beaf): Code: 117. DB::Exception: ... INCORRECT_DATA: JSON object/array should start with corresponding opening bracket., server keeps running.
  • New test 04238 10/10 passes.

(f) Fix is general, not a narrow patch? YES — searched all call sites of supportsDelete() and supportsParallelInsert():

  • InterpreterDeleteQuery.cpp:92 — fixed by supportsDelete() change.
  • InsertDependenciesBuilder.cpp:768 — fixed by supportsParallelInsert() change.
  • supportsLightweightDelete is NOT overridden by StorageObjectStorage (inherits IStorage default false) — no gap.
  • supportsWrites is called from StorageObjectStorage::write() AFTER a configuration->update() for non-data-lake configurations, and lazy-init runs from getInMemoryMetadataPtr paths for data lakes — no gap.

Also asked "Am I fixing the root cause or just guarding against the symptom?" — YES, lazyInitializeIfNeeded triggers the actual metadata load, surfacing the real error instead of masking it with assertInitialized. Not a defensive null guard.

Session: cron:clickhouse-ci-task-worker:20260514-074500

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @alesapin @Michicosun @asya-ch — could you review this? It is the follow-up to #104738 for the supportsDelete / supportsParallelInsert gap that @clickgapai filed as #104891. The lazy-init is added at the StorageObjectStorage layer (matching the existing pattern of supportedPrewhereColumns / getColumnSizes in the same file) rather than extending the virtual signature change in DataLakeConfiguration, since supportsDelete() is reached BEFORE any of the four methods covered by #104738.

cc @PedroTadim @scanhex12

@PedroTadim

Copy link
Copy Markdown
Member

@groeneai can you add a few more test cases with queries similar to DELETE such as TRUNCATE, UPDATE, INSERT, ALTER DELETE/UPDATE?

@nikitamikhaylov nikitamikhaylov added the can be tested Allows running workflows for external contributors label May 14, 2026
@clickhouse-gh

clickhouse-gh Bot commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d3ededb]

Summary: ✅


AI Review

Summary

This PR adds lazy initialization before StorageObjectStorage delegates supportsDelete and supportsParallelInsert to data lake metadata, so freshly attached Iceberg, DeltaLake, or Hudi tables with unloadable metadata surface a regular exception instead of LOGICAL_ERROR: 'Metadata is not initialized'. The current code and the new MV-dependent INSERT regression cover the live gap, and I do not see a code-level blocker.

PR Metadata
  • 💡 Changelog category is correct as Bug Fix.
  • 💡 Changelog entry is required and mostly clear, but the final diff also fixes the INSERT-through-MATERIALIZED VIEW path via supportsParallelInsert; the current entry only mentions DELETE FROM.

Suggested replacement:

Fix `Logical error: 'Metadata is not initialized'` exceptions for freshly attached `Iceberg`, `DeltaLake`, or `Hudi` tables whose metadata file is corrupted or unloadable. The affected `DELETE FROM` and `INSERT`-through-`MATERIALIZED VIEW` planning paths now report a regular user-facing exception, and the server keeps running. Closes #104891.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label May 14, 2026
Per the request from @PedroTadim on ClickHouse#104917, the regression test now
covers the full shape of operations that reach the lazy-init guard:

- DELETE FROM (the primary repro - empirically crashes the server in
  the corrupted-metadata + DETACH/ATTACH state when the
  `supportsDelete` lazy-init guard is absent, raising `Logical error:
  'Metadata is not initialized'`)
- TRUNCATE TABLE
- UPDATE (lightweight)
- INSERT INTO (the `supportsParallelInsert` half of the fix)
- ALTER TABLE ... DELETE (mutation, already covered by 04230 but kept
  here for completeness against the corrupted-metadata state)
- ALTER TABLE ... UPDATE (sibling)

Each case runs on a fresh corrupted-metadata table so the operation is
exercised against uninitialized metadata - any preceding operation
that completed the lazy-init would mask the bug.

Empirically only `DELETE FROM` reaches the `assertInitialized` call
site in this scenario (the other paths fail with `INCORRECT_DATA`
earlier in their pipelines), and only `DELETE` triggers a server abort
when the `supportsDelete` lazy-init is reverted. The remaining cases
are shape coverage: they document that the fix does not regress these
operations and guard against future refactors that could move the
`supports*` call earlier in the pipeline.

The test passes 10/10 with the fix; reverting the supportsDelete /
supportsParallelInsert lazy-init guards causes the DELETE case to
abort the server with `Logical error: 'Metadata is not initialized'`.
@groeneai

Copy link
Copy Markdown
Collaborator Author

Pushed 0dc60f9381c expanding the regression test per @PedroTadim's request and the bot's inline comment.

What the test now covers (tests/queries/0_stateless/04238_iceberg_supports_delete_metadata_not_initialized_104891.sh):

Each case runs on a fresh corrupted-metadata table (DETACH ... SYNC + ATTACH) so the operation is exercised against uninitialized current_metadata. The exact error code raised depends on what update happens to fail with for the corrupted metadata file; the test only asserts that it is not Logical error: 'Metadata is not initialized' and that the server stays alive.

Case Query What it exercises
delete DELETE FROM ... WHERE c0 = 0 The supportsDelete lazy-init guard — empirically crashes the server in this scenario without the fix
truncate TRUNCATE TABLE ... Shape coverage
update UPDATE ... SET c0 = 1 WHERE c0 = 0 Shape coverage
insert INSERT INTO ... VALUES (3) The supportsParallelInsert half of the fix (shape coverage in this scenario)
alter_delete ALTER TABLE ... DELETE WHERE c0 = 0 Shape coverage (also covered by 04230)
alter_update ALTER TABLE ... UPDATE c0 = 1 WHERE c0 = 0 Shape coverage

Empirical note for transparency: in this corrupted-metadata scenario only DELETE FROM actually reaches the assertInitialized call site — the other operations fail with INCORRECT_DATA earlier in their pipelines (the INSERT pipeline triggers a metadata load that throws INCORRECT_DATA before reaching InsertDependenciesBuilder::supportsParallelInsert). I verified this by:

  1. With the fix in place: 10/10 runs pass (all 6 cases × 10 iterations).
  2. Reverting the supportsDelete / supportsParallelInsert lazy-init guards locally and re-running: only the delete case aborts the server with Logical error: 'Metadata is not initialized'; the rest of the cases would also be aborted because the first abort kills the server.
  3. Manual repro of each case against the reverted binary confirms INSERT INTO ... VALUES, INSERT INTO ... SELECT, TRUNCATE, lightweight UPDATE, and the two ALTER shapes all produce INCORRECT_DATA: JSON object/array should start with corresponding opening bracket (the metadata-load failure surfacing earlier), not a logical error.

The extra cases are kept as shape coverage: they document that the fix doesn't regress these operations and guard against future refactors that could move the supports* call earlier in the pipeline.

cc @PedroTadim @asya-ch

…` lazy-init

Follow-up to ClickHouse#104891 and
the bot AI review on PR ClickHouse#104917 - covers the dependent-sink path that
test `04238` does not reach.

When an `INSERT` lands on a non-datalake source with a `MATERIALIZED VIEW`
whose target is a freshly-attached data lake table,
`InsertDependenciesBuilder` queries `storage->supportsParallelInsert` for
every non-view sink at `src/Interpreters/InsertDependenciesBuilder.cpp:768`.
`InterpreterInsertQuery::execute` only calls
`updateExternalDynamicMetadataIfExists` for the root insert target
(`src/Interpreters/InterpreterInsertQuery.cpp:1027`), so the data lake
target reached via the MV stays uninitialized and the
`assertInitialized()` inside
`DataLakeConfiguration::supportsParallelInsert` raises
`LOGICAL_ERROR: 'Metadata is not initialized'` - fatal in debug and
sanitizer builds.

Empirical FAIL -> PASS:

- Reverted only the `supportsParallelInsert` lazy-init guard introduced
  by this PR. The test makes the server SIGABRT during
  `INSERT INTO source VALUES (3)`. Server log:
  `Fatal: Logical error: 'Metadata is not initialized'.`
  Stack: `DataLakeConfiguration<StorageLocalConfiguration,
  IcebergMetadata>::supportsParallelInsert() const`
  -> `StorageObjectStorage::supportsParallelInsert() const`.
  The `SELECT 1` aliveness probe at the end then hits connection
  refused, and `clickhouse-test` reports the run as `[ FAIL ]`.

- Restored guard: 10/10 PASS. Test `04238` still passes (no regression).
@groeneai

Copy link
Copy Markdown
Collaborator Author

Pushed 8567be08f31 adding tests/queries/0_stateless/04240_iceberg_supports_parallel_insert_mv_104891.{sh,reference} for the dependent-sink path that the bot's previous inline comment called out.

Why a separate test

Test 04238 exercises the six direct-query shapes through the same corrupted-metadata table. The dependent-sink path needs a different scaffold (root MergeTree source + MATERIALIZED VIEW TO <datalake_target>), so it lives in its own file rather than as a 7th case in run_case.

What it covers

CREATE TABLE datalake_target (c0 Int32)
ENGINE = IcebergLocal('/.../datalake_target/')
SETTINGS iceberg_metadata_compression_method = 'deflate';

-- corrupt on-disk metadata
INSERT INTO datalake_target VALUES (2) SETTINGS allow_insert_into_iceberg=1,
                                                output_format_compression_level=11;

CREATE TABLE source (c0 Int32) ENGINE = MergeTree ORDER BY tuple();
CREATE MATERIALIZED VIEW mv TO datalake_target AS SELECT c0 FROM source;

DETACH TABLE datalake_target SYNC;
ATTACH TABLE datalake_target;

INSERT INTO source VALUES (3);   -- reaches supportsParallelInsert on the
                                 -- freshly-attached data-lake target via
                                 -- InsertDependenciesBuilder
SELECT 1;                        -- aliveness probe

The decisive assertion is the final SELECT 1: if the supportsParallelInsert lazy-init guard isn't there, the assertion in DataLakeConfiguration::supportsParallelInsert raises Logical error: 'Metadata is not initialized', chassert turns it into SIGABRT in debug / sanitizer builds, and the probe hits connection refused.

Empirical FAIL → PASS

To verify the test catches the bug it's meant to catch, I temporarily reverted only the supportsParallelInsert guard introduced by this PR (left supportsDelete alone), rebuilt, and reran the new test against that binary:

04240_iceberg_supports_parallel_insert_mv_104891:                       [ FAIL ] 8.35 sec.
[mv_to_datalake] target INSERT failed as expected
[mv_to_datalake] client did not receive Logical error
[mv_to_datalake] FAIL: server unreachable after dependent-sink INSERT

Server log on that run:

<Fatal> : Logical error: 'Metadata is not initialized'.
DataLakeConfiguration<StorageLocalConfiguration, IcebergMetadata>::supportsParallelInsert() const @ DataLakeConfiguration.h:141
StorageObjectStorage::supportsParallelInsert() const @ StorageObjectStorage.cpp:382
BaseDaemon: Received signal 6 (internal)
BaseDaemon: Signal description: Aborted

Triggering query: INSERT INTO test_<db>.mv_source_<rand> (c0) FORMAT Values.

Then I restored the guard, rebuilt, and reran:

04240_iceberg_supports_parallel_insert_mv_104891:                       [ OK ] 2.19 sec.   x 10
04238_iceberg_supports_delete_metadata_not_initialized_104891:          [ OK ] 6.30 sec.

10/10 PASS on the new test plus the existing 04238 test still passes — so the fix continues to cover both the direct DELETE path and the new MV-dependent-sink path, and nothing regresses.

Pre-PR validation gate (TASK.md Phase 4 step 9)

  • (a) Deterministic repro: yes — INSERT into the MV's source crashes the server on every run when the guard is removed.
  • (b) Root cause: InsertDependenciesBuilder::buildPipeline queries supportsParallelInsert on every non-view sink; InterpreterInsertQuery::execute only primes metadata for the root insert target. A data-lake target reached through an MV stays uninitialized.
  • (c) Fix matches root cause: lazy-init guard in StorageObjectStorage::supportsParallelInsert mirrors supportedPrewhereColumns / getColumnSizes in the same file (precedent endorsed by @Michicosun for CurrentThread::tryGetQueryContext in mutation-related paths on parent PR Initialize data lake metadata before OPTIMIZE / ALTER on attach #104738).
  • (d) Test intent: new file, no existing test relaxed.
  • (e) Both directions demonstrated: see the FAIL output and 10/10 PASS above.
  • (f) Fix general: same guard pattern as the supportsDelete half of this PR, applied to the only other supports* method that reaches assertInitialized in DataLakeConfiguration.h. Resolved bot comment.

cc @PedroTadim @asya-ch

@clickgapai

Copy link
Copy Markdown
Contributor

@groeneai LGTM — the fix is sound.

The call-site placement is correct: InterpreterDeleteQuery::execute calls supportsDelete() before checkMutationIsPossible, and the new methods properly mirror the existing lazyInitializeIfNeeded → delegate pattern used for checkMutationIsPossible, checkAlterIsPossible, and write.

Const-correctness is valid since we're modifying the pointee through a shared_ptr, not the method's object itself.

Note: There's a pre-existing TOCTOU race in lazyInitializeIfNeeded (check-then-assign without mutex), but this isn't introduced by this PR — the same pattern already exists for other methods.

Tests 04238 and 04240 provide good coverage for the direct-query and MV-dependent-sink paths.

@alexey-milovidov alexey-milovidov 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.

Ok.

@alexey-milovidov alexey-milovidov self-assigned this May 17, 2026
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label May 20, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

Refreshed master 6a67f03bb9c via workflow-restore trick to trigger a fresh sync run.

The previous CH Inc sync "failure" was 21+ test_e2e_catalogs/test.py::*[onelake] integration tests (only the [onelake] parametrization, all other catalog backends pass). The failures span pure SELECT operations (test_select_count, test_projection_pushdown, test_where_filter, …) which never call supportsDelete or supportsParallelInsert — the two methods this PR modifies. Related to the existing OneLake backend bug clickhouse-private#51399, not to this change.

The prior commit deleted/modified workflow files in this branch as a
workaround for GitHub's workflow-scope check. Restoring them to match
`master` so the PR diff no longer contains unrelated changes.
@PedroTadim

Copy link
Copy Markdown
Member

@scanhex12 and @divanik can you review this PR before merging it?

@PedroTadim

Copy link
Copy Markdown
Member

@groeneai check the CI failure, maybe you need to create another PR with the fix

PR ClickHouse#102882 (Smita Kulkarni, merged 2026-05-28) added
table->updateExternalDynamicMetadataIfExists() in
InterpreterDeleteQuery::execute before the table->supportsDelete()
call. That upstream fix initializes the data lake metadata before
supportsDelete reaches assertInitialized, so the Logical error path
that 04238 was designed to catch is no longer reachable via DELETE
FROM on master HEAD.

The other five cases in 04238 (TRUNCATE, UPDATE, INSERT, ALTER DELETE,
ALTER UPDATE) were documented in the test as shape-coverage-only:
the corrupted-metadata setup errors with INCORRECT_DATA before
reaching the supports* methods.

04240 stays. It covers the InsertDependenciesBuilder
supportsParallelInsert path on MV-dependent sinks, which has no
upstream lazy-init guard and which our StorageObjectStorage
wrapper does fix.

The StorageObjectStorage::supportsDelete wrapper is kept as
defense in depth, mirroring the checkMutationIsPossible /
checkAlterIsPossible wrappers added by parent PR ClickHouse#104738.
@groeneai

Copy link
Copy Markdown
Collaborator Author

@PedroTadim Checked. Three CI signals:

1. Bugfix validation (functional tests) FAIL. Actionable. Test 04238_iceberg_supports_delete_metadata_not_initialized_104891 no longer fails on master HEAD. PR #102882 (merged 2026-05-28) added table->updateExternalDynamicMetadataIfExists(getContext()) at InterpreterDeleteQuery::execute:97, upstream of the supportsDelete() call. That initializes the data lake metadata before assertInitialized runs, so the Logical error: Metadata is not initialized path that 04238 was designed to catch is no longer reachable on master via DELETE FROM. The other 5 cases in 04238 (TRUNCATE / UPDATE / INSERT / ALTER DELETE / ALTER UPDATE) were marked shape-coverage-only in the test comments because the corrupted-metadata setup hits INCORRECT_DATA before reaching the supports* method.

04240_iceberg_supports_parallel_insert_mv_104891 still fails on master HEAD as designed. The MV-dependent sink path reaches InsertDependenciesBuilder::supportsParallelInsert -> StorageObjectStorage::supportsParallelInsert -> DataLakeConfiguration::supportsParallelInsert -> assertInitialized -> SIGABRT, with no upstream lazy-init guard. That is what this PR fixes.

Dropped 04238 in aeddd47. Kept the supportsDelete wrapper as defense in depth (mirrors the checkMutationIsPossible / checkAlterIsPossible wrappers added by parent PR #104738). Kept 04240 + the supportsParallelInsert wrapper as the live fix.

2. Stateless tests (amd_asan_ubsan, db disk, distributed plan, sequential) SEGV. STID 4307-587a, single occurrence in CIDB across the last 90 days (this run only). Stack is __asan::QuarantineCallback::Recycle reached via MergeTreeData::clearPartsFromFilesystemImplMaybeInParallel -> IMergeTreeDataPart::remove -> DataPartStorageOnDiskBase::clearDirectory -> ~path. ASAN quarantine corruption in a background MergeTree parts cleanup thread. The PR only touches StorageObjectStorage and IcebergLocal test plumbing, neither of which interacts with MergeTree parts cleanup. Treating as a one-shot infra flake; no separate PR unless it recurs.

3. CH Inc sync. Unchanged from your 2026-05-27 triage and @alexey-milovidov's 2026-05-20 note: test_e2e_catalogs/test.py::*[onelake] only, tied to clickhouse-private#51399, unrelated to this PR.

@groeneai

Copy link
Copy Markdown
Collaborator Author

@PedroTadim both bot inline findings addressed on top of aeddd479e7b4:

  • ac131171b495 — reworded the supportsDelete comment to describe defense in depth after the master rebase. InterpreterDeleteQuery::execute now pre-initialises via updateExternalDynamicMetadataIfExists (since ClickHouse#102882), so this wrapper is no longer the primary preventing path for DELETE FROM; it is kept to mirror supportsParallelInsert and to protect any other caller.
  • d3ededb6a4b7 — repointed the 04240 companion-test comment from the dropped 04238 to its actual parent regression test 04230_iceberg_optimize_metadata_not_initialized_104711.

Comment-only fixups, no code change.

@clickhouse-gh

clickhouse-gh Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.40% 84.40% +0.00%
Functions 91.40% 91.40% +0.00%
Branches 77.00% 77.00% +0.00%

Changed lines: Changed C/C++ lines covered by tests: 5/8 (62.50%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue May 31, 2026
Merged via the queue into ClickHouse:master with commit f15873b May 31, 2026
166 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 31, 2026
robot-ch-test-poll added a commit that referenced this pull request Jun 9, 2026
Cherry pick #104917 to 26.4: Fix `Metadata is not initialized` on `DELETE FROM` for data lakes
robot-clickhouse added a commit that referenced this pull request Jun 9, 2026
robot-ch-test-poll added a commit that referenced this pull request Jun 9, 2026
Cherry pick #104917 to 26.5: Fix `Metadata is not initialized` on `DELETE FROM` for data lakes
robot-clickhouse added a commit that referenced this pull request Jun 9, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Jun 9, 2026
@robot-clickhouse robot-clickhouse added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jun 9, 2026
alexey-milovidov added a commit that referenced this pull request Jun 10, 2026
Backport #104917 to 26.5: Fix `Metadata is not initialized` on `DELETE FROM` for data lakes
alexey-milovidov added a commit that referenced this pull request Jun 10, 2026
Backport #104917 to 26.4: Fix `Metadata is not initialized` on `DELETE FROM` for data lakes
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…4917

Backport ClickHouse#104917 to 26.4: Fix `Metadata is not initialized` on `DELETE FROM` for data lakes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors manual approve Manual approve required to run CI pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.4-must-backport v26.5-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

supportsDelete in DataLakeConfiguration throws LOGICAL_ERROR on freshly-attached data lake table with uninitialized metadata

9 participants