Repository navigation
Cherry pick #104917 to 26.4: Fix Metadata is not initialized on DELETE FROM for data lakes - #106889
Merged
Merged
Conversation
`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 #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 #104891 Related: #104711, #104738 Co-Authored-By: Claude Opus 4.7 <[email protected]>
Per the request from @PedroTadim on #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'`.
…` lazy-init Follow-up to #104891 and the bot AI review on PR #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).
…ts-delete-datalake-104891
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.
…ts-delete-datalake-104891
PR #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 #104738.
…-datalake-104891 Fix `Metadata is not initialized` on `DELETE FROM` for data lakes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Original pull-request #104917
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-picklocally.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.
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:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job