Found via ClickGap automated review. Please close or comment if this is incorrect or needs adjustment.
Describe what's wrong
DELETE FROM table WHERE ... on a freshly-attached Iceberg/DeltaLake/Hudi table with corrupted or unloadable metadata throws LOGICAL_ERROR: Metadata is not initialized instead of a user-facing exception
Root cause: DataLakeConfiguration.h:133-137: supportsDelete() calls assertInitialized() instead of lazyInitializeIfNeeded(). Unlike the four methods fixed by this PR (optimize, alter, checkMutationIsPossible, checkAlterIsPossible), supportsDelete() was not updated to use lazy initialization.
Why we believe this is a bug: InterpreterDeleteQuery::execute() (line 92) calls table->supportsDelete() → StorageObjectStorage::supportsDelete() → DataLakeConfiguration::supportsDelete() (line 133-137) which calls assertInitialized(). The PR fixes checkMutationIsPossible but not supportsDelete() which is called BEFORE checkMutationIsPossible in the DELETE FROM path.
Affected locations:
src/Storages/ObjectStorage/DataLakes/DataLakeConfiguration.h:133 — supportsDelete() calls assertInitialized()
Impact: DELETE FROM queries on freshly-attached data lake tables with uninitialized metadata throw LOGICAL_ERROR, which crashes debug/sanitizer builds and produces confusing error messages in release builds.
Does it reproduce on most recent release?
Yes — confirmed on current master (commit 1732358b6ce).
How to reproduce
Requires IcebergLocal support and user_files_path access (cannot run in Fiddle).
-- Setup
CREATE TABLE test_datalake (c0 Int32)
ENGINE = IcebergLocal('/var/lib/clickhouse/user_files/test_datalake/')
SETTINGS iceberg_metadata_compression_method = 'deflate';
-- Corrupt metadata by using incompatible compression level
INSERT INTO test_datalake VALUES (2)
SETTINGS allow_insert_into_iceberg=1, output_format_compression_level=11;
-- This INSERT fails with INCORRECT_DATA (expected)
-- DETACH/ATTACH to get uninitialized metadata state
DETACH TABLE test_datalake SYNC;
ATTACH TABLE test_datalake;
-- BUG: This throws LOGICAL_ERROR instead of user-facing exception
DELETE FROM test_datalake WHERE c0 = 1
SETTINGS allow_insert_into_iceberg=1;
-- Cleanup
DROP TABLE IF EXISTS test_datalake SYNC;
Expected behavior
INSERT failed as expected
DELETE FROM did not crash with LOGICAL_ERROR
1
Error message and/or stacktrace
INSERT failed as expected
BUG: DELETE FROM crashed with LOGICAL_ERROR
1
Additional context
Open risks:
supportsParallelInsert() at line 139-143 has the same issue but the code path to reach it without initialization may be protected by earlier update() calls
mutate() at line 145-154 has assertInitialized() but is called after checkMutationIsPossible which now initializes metadata
Suggested fix: Change supportsDelete() to take ObjectStoragePtr and ContextPtr parameters and call lazyInitializeIfNeeded() instead of assertInitialized(), matching the pattern used for the other fixed methods. Also need to update StorageObjectStorage::supportsDelete() to pass the required parameters.
Analysis details: Confidence HIGH | Severity P1 | Testability: STATELESS_SQL
Found during automated review of PR #104738.
ClickGapAI · Confidence: HIGH · Severity: P1 · Finding: h_pr104738_001
Found via ClickGap automated review. Please close or comment if this is incorrect or needs adjustment.
Describe what's wrong
DELETE FROM table WHERE ...on a freshly-attached Iceberg/DeltaLake/Hudi table with corrupted or unloadable metadata throwsLOGICAL_ERROR: Metadata is not initializedinstead of a user-facing exceptionRoot cause: DataLakeConfiguration.h:133-137:
supportsDelete()callsassertInitialized()instead oflazyInitializeIfNeeded(). Unlike the four methods fixed by this PR (optimize, alter, checkMutationIsPossible, checkAlterIsPossible),supportsDelete()was not updated to use lazy initialization.Why we believe this is a bug:
InterpreterDeleteQuery::execute()(line 92) callstable->supportsDelete()→StorageObjectStorage::supportsDelete()→DataLakeConfiguration::supportsDelete()(line 133-137) which callsassertInitialized(). The PR fixescheckMutationIsPossiblebut notsupportsDelete()which is called BEFOREcheckMutationIsPossiblein the DELETE FROM path.Affected locations:
src/Storages/ObjectStorage/DataLakes/DataLakeConfiguration.h:133— supportsDelete() calls assertInitialized()Impact: DELETE FROM queries on freshly-attached data lake tables with uninitialized metadata throw LOGICAL_ERROR, which crashes debug/sanitizer builds and produces confusing error messages in release builds.
Does it reproduce on most recent release?
Yes — confirmed on current
master(commit1732358b6ce).How to reproduce
Requires
IcebergLocalsupport anduser_files_pathaccess (cannot run in Fiddle).Expected behavior
Error message and/or stacktrace
Additional context
Open risks:
supportsParallelInsert()at line 139-143 has the same issue but the code path to reach it without initialization may be protected by earlier update() callsmutate()at line 145-154 has assertInitialized() but is called after checkMutationIsPossible which now initializes metadataSuggested fix: Change
supportsDelete()to takeObjectStoragePtrandContextPtrparameters and calllazyInitializeIfNeeded()instead ofassertInitialized(), matching the pattern used for the other fixed methods. Also need to updateStorageObjectStorage::supportsDelete()to pass the required parameters.Analysis details: Confidence HIGH | Severity P1 | Testability:
STATELESS_SQLFound during automated review of PR #104738.
ClickGapAI · Confidence: HIGH · Severity: P1 · Finding:
h_pr104738_001