Repository navigation
Conversation
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-5:20260701-133700 |
|
cc @scanhex12 @divanik — could you review this? It fixes |
|
Workflow [PR], commit [8480ef5] Summary: ❌
AI ReviewSummaryThe PR makes Missing context / blind spots
Findings❌ Blockers
Tests
Final VerdictStatus: ❌ Block Prevent deletion of another table and restoration/exposure of partially deleted tables. Address or explicitly track the version 1 cleanup and restart-durability gaps. Previously dismissed concerns remain confined to this summary; their inline threads were not reopened or repeated. |
|
Follow-up commit 5e56bda extends the fix to the DataLakeCatalog path (per the bot review). Pre-PR validation gate for the follow-up: Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-8:20260701-155000 |
CI finish ledger — 4e31967CI has fully finished (Mergeable Check completed). Every failure below has an owner; only
Notes:
Session id: cron:our-pr-ci-monitor:20260701-210000 |
|
Pre-PR validation gate for the parallel-replicas catalog-drop fix (commit 0f251a6): Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-1:20260701-212300 |
|
The |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-4:20260701-225900 |
|
Pre-PR validation gate for fadc690 (partial-drop atomicity fix). Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-0:20260702-004300 |
CI finish ledger — fadc690CI is complete and green on this head. Every check passes; only
Session id: cron:our-pr-ci-monitor:20260702-053000 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-0:20260702-052700 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-1:20260702-071500 |
|
Follow-up on the restart-durable async-drop gap the bot raised above (mechanism confirmed in my earlier reply on this thread, r3511954160). Tracking it separately from this PR as agreed. Before anyone implements, I would like your call on the direction, since both viable fixes are core-layer changes I do not want to pick unilaterally:
@alesapin as the Iceberg owner: option 1, option 2, or document as a known limitation? No urgency, this is a post-merge follow-up and not a blocker for this PR. The decision itself is independent of the merge, so answering now is fine; I will only implement after this merges. Whichever you pick I will cover all three affected engines ( |
CI finish ledger - ac5fc3cCI fully finished and green on this head. No failed checks; every job is SUCCESS (including the 4 Bugfix validation and all Integration test lanes). The
Session id: cron:our-pr-ci-monitor:20260702-133000 |
|
@groeneai : Please delete only the files reachable from the table's own metadata (collectReachableFiles, which already takes the root from the catalog and ignores iceberg_metadata_file_path) instead of sweeping everything under table_path, because tables can share a location and dropping one would delete the other's data as you mentioned in couple of your comments |
Tables can share a location, and one can be stored inside another table's directory, so listing everything under the table path and deleting it destroyed the files of tables that were not dropped. DROP now deletes the files reachable from the table's metadata (`collectReachableFiles`, which takes the root from the catalog when there is one), plus the metadata files `metadata-log` misses: ClickHouse does not log the version written by CREATE or by a schema change, so those are matched by `table-uuid`. A retried drop of an Atomic table reuses the collected list, because the metadata it was collected from may already be partly deleted. The list can name files that do not exist (`version-hint.text`), so in a database that reattaches the table after a failed DROP, such a file no longer counts as the first deleted one, which made the next failure ignored. Tests: `04365` keeps a table stored inside the dropped table's directory, `test_tables_with_same_location` keeps the other table at the shared location, `04366` fails the DROP of a table without data files. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Done in e938b95: One addition was needed. ClickHouse does not put the metadata file written by Tests: |
In a Replicated database every replica drops its copy of the table, and the copies share one location. Since `drop()` collects the files from the latest metadata, every replica after the first one fails with `FILE_DOESNT_EXIST`, `DatabaseCatalog` retries it every 5 seconds forever, and `DROP TABLE ... SYNC` / `DROP DATABASE ... SYNC` on that replica never returns (Stateless tests (arm_binary, s3 storage, DBReplicated, parallel, 1/2): the replicated DDL queue stalled and the job stopped at `--max-failures`). The initiator does not wait for that replica, so a table created at the location in the meantime is deleted by the retry. Before deleting, look at the metadata files at the location: when none of them carries the table's own `table-uuid` (compared as an optional, so a table without one is told apart from a table with one), delete nothing. A retry of an earlier failed attempt still deletes its remaining files when the location holds no metadata at all, but not when another table is there. The files are read bypassing the metadata cache: it is keyed by the table uuid and the file name, so it would return this table's old content for a file name the new table reuses. Measured with two replicas sharing one `IcebergLocal` path: before, the second replica retried 482 times in 40 minutes, its `DROP DATABASE SYNC` hung, and a re-created table lost `v1.metadata.json`; after, the second replica logs "nothing to delete" and returns, and the new table is intact. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A table attached by `ATTACH` or at server startup loads its Iceberg metadata lazily, so a DROP with `iceberg_delete_data_on_drop = 1` reads the table identity from the files that are at the path at drop time. In a `Replicated` database every replica replays the DROP on the same files, which gave two failures for a replica whose table was not read since startup: - The initial replica has already deleted the files: the metadata init throws `FILE_DOESNT_EXIST`, and the background drop retries every 5 s forever, so `DROP ... SYNC` and the replica's DDL queue hang. - The replica was down while the table was dropped and another table was created at the path: its replay adopts the new table's `table-uuid`, passes the ownership check and deletes the new table's files. Only the initial run of a `Replicated` database's DDL creates the Iceberg table (a replay is `SECONDARY_CREATE`), so a replayed DROP no longer deletes data either. A lazy init that finds no metadata file left means there is nothing to delete. Measured with two servers in one `Replicated` database sharing an IcebergLocal path: before, the restarted replica retried the drop forever (first case) and deleted all 5 files of the new table, whose SELECT then failed with code 107 (second case); after, neither happens. Co-Authored-By: Claude Opus 5.5 <[email protected]>
| auto reachable = Iceberg::collectReachableFiles( | ||
| object_storage, persistent_components, data_lake_settings, context, log, catalog, storage_id.getTableName()); |
There was a problem hiding this comment.
[P2] Support version 1 metadata in the new cleanup traversal
This newly used helper assumes version 2 metadata: for any nonempty snapshots, SnapshotFilesTraversal.cpp:179 unconditionally reads current-schema-id. That field is optional in version 1 (Iceberg specification), and the existing reader supports its absence through parseTableSchemaV1Method, using schema.schema-id. The helper's existing remove_orphan_files caller explicitly rejects version 1 before invoking it; this caller has no corresponding restriction.
A readable, populated version 1 table without current-schema-id therefore throws before cleanup. In an Atomic database, background cleanup retries the same deterministic exception indefinitely, and DROP TABLE ... SYNC cannot finish. Make the traversal handle the supported version 1 representation and add a regression using version 1 metadata without the optional version 2 fields.
Two gaps in the delete-on-drop cleanup of an Iceberg table: 1. Without a catalog, `collectReachableFiles` roots at the latest metadata file at the table path, chosen by version and not by table UUID. When the location also holds another table's newer metadata file, the ownership guard passes (this table's own files are still there), the traversal follows the other table's graph, and dropping this table deleted the other one. Measured: after the drop the other table's SELECT returned no rows instead of its two. Now the cleanup keeps every file when the UUID of the root differs from the one the table was loaded with. The traversal no longer reads through the metadata cache, like the ownership scan before it: when the other table's root reuses a file name this table read before, the cache returns this table's old content for it, the UUID check passes, and the other table's metadata was deleted. Selecting the root by UUID instead (as `iceberg_metadata_table_uuid` does) was not taken: that selection throws on any metadata file at the location without a `table-uuid`, so a background drop would retry forever. 2. Data files were told from the rest by their extension, `.parquet` or `.orc`. Avro data files were deleted with the metadata files, after the catalog drop, so for a catalog table a failed delete of one was ignored and the DROP succeeded with no catalog entry to retry through. The traversal now returns the data and delete files it read from the manifests, and the cleanup uses them. Tests: 04365 keeps a table whose newer metadata, under a file name the dropped table used before, sits at the dropped table's path; 04366 adds an Avro table to the first-delete failure arm. Both fail before the change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Without a catalog, `drop()` keeps every file when the latest metadata file at the location carries a `table-uuid` other than the dropped table's. That check required the dropped table's own uuid to be known, so a format version 1 table loaded without `table-uuid` (optional in v1) skipped it: with another table's higher-version metadata file (which has a uuid) at the same location, dropping the v1 table with `iceberg_delete_data_on_drop = 1` deleted the other table's metadata, manifests and data, and that table then read 0 rows. Compare the two optional uuids directly, so a root with a uuid is never followed by a table without one. ClickHouse never adds a `table-uuid` to an existing table (writes copy the previous metadata), so a uuid-less table's own later versions stay uuid-less and are still cleaned up. Two uuid-less tables at one location remain indistinguishable, as before. The 04365 shared-location case now also runs with a format version 1 table whose metadata has no `table-uuid`; it fails without the change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`collectReachableFiles` adds `metadata/version-hint.text` unconditionally, but the hint belongs to the location, not to a table. When another table's metadata file stays at the location (for example a table selected there with `iceberg_metadata_table_uuid`), that table can read through the hint (`iceberg_use_version_hint = 1`), and deleting it made its next read fail with FILE_DOESNT_EXIST. Now the hint is deleted only when every metadata file at the location is this table's; a metadata file whose owner cannot be told (no `table-uuid`) counts as another table's. A kept hint that names a deleted file is harmless: a numeric hint that resolves to no file falls back to listing. The shared-location case of 04365 now reads the other table through its version hint after a table selected by `iceberg_metadata_table_uuid` is dropped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A REST catalog (and S3 Tables, which is one) gets `purgeRequested=true` on DROP with `iceberg_delete_data_on_drop`, and the catalog server deletes the files. ClickHouse still deleted the data files itself before asking for the purge, so ClickHouse now needed `s3:DeleteObject` on the table location even when the catalog can purge with its own credentials. Measured with the REST fixture and a MinIO user allowed only to read and list, used as the DataLakeCatalog storage credentials: - master: DROP succeeds, purge requested, 0 files left; - f1d4035: DROP fails with Access Denied on the first data file, the table stays in the catalog; - this commit: DROP succeeds, purge requested, 0 files left, no delete sent by ClickHouse. `supportsDropTable()` is replaced by `keepsFilesOnDrop()`, true only for Glue, whose DeleteTable leaves the files: only there does ClickHouse delete them (data, catalog entry, metadata). Every other catalog either purges or cannot drop at all, and is asked first. Tests: the REST retry test now asserts that a failed catalog drop deletes no file (fails on f1d4035), and the two failure-path cases that only the client-side deletion reaches moved to `test_database_glue`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
UnityV2Catalog now implements dropTable (ClickHouse#124481): for an external table it refuses `iceberg_delete_data_on_drop = 1` with SUPPORT_IS_DISABLED before sending anything, instead of the base ICatalog NOT_IMPLEMENTED. The file and row assertions are unchanged; a mutant that sends Unity down the client-side delete path still fails them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
After the master merge, IcebergMetadata::data_lake_settings is a DataLakeStorageSettingsPtr instead of a reference, so the drop cleanup call no longer compiled (Build (arm_tidy, 1/4) on f8b21bf). Pass *data_lake_settings, like the other call sites in this file. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - 88eb78bEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
CIDB has no other Session id: cron:our-pr-ci-monitor:20261024-100006 |
…eanup-108524 Resolve the conflicts in IDataLakeMetadata.cpp and test_database_iceberg/test.py by keeping both sides.
|
Dear @SmitaRKulkarni, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
…eanup-108524 Resolve the conflicts in IcebergMetadata.cpp, StorageObjectStorage.cpp and StorageObjectStorage.h by keeping both sides. The CREATE existence check keeps its version-hint predicate and lists only the direct children of `metadata/`, as master now does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Without a catalog, the drop walked the latest metadata file's manifests before checking that the file belongs to the dropped table. At a location shared with another table whose manifests do not fit this table's schemas (a String column partitioned by day in the other table, or any conflicting schema with iceberg_tolerate_conflicting_manifest_schemas = 0), the walk threw ILLEGAL_TYPE_OF_ARGUMENT / ICEBERG_SPECIFICATION_VIOLATION, so an Atomic table was retried in the background forever and DROP TABLE ... SYNC never returned. The root is now resolved and checked first, and the traversal starts from it (collectReachableFilesFromRoot), so the other table is left alone and the drop finishes. 04365's shared-location case now uses such a table. The cleanup also no longer builds a separate list of metadata files while deleting data files: an allocation failure there, after a data file was deleted, escaped the best-effort handling of a reattaching drop. The set is iterated twice instead. Also drop the duplicate <Common/FailPoint.h> include the last master merge left (Build (arm_tidy, 1/4): readability-duplicate-include). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed
DROP TABLEon an Iceberg table withiceberg_delete_data_on_drop = 1not deleting the table's files, which made re-creating a table at the same path fail withTABLE_ALREADY_EXISTS.Description
Closes: #108524
Since at least v25.9,
DROP TABLEwithiceberg_delete_data_on_drop = 1kept the files. Two bugs:IcebergMetadata::droppassed the table path as both the listing base and the prefix, so it matched nothing. Tables can share a location, so it now deletes only the files reachable from the table's metadata (collectReachableFiles), plus the metadata files with the sametable-uuidthatmetadata-logmisses. In a Replicated database only the replica that receives the DROP deletes files, and nothing is deleted when no metadata file, or not the latest one, carries the table'stable-uuid.drop()runs in a background pool and readiceberg_delete_data_on_dropfrom the global context, alwaysfalse. The query settings are now captured incheckTableCanBeDropped, whichDatabaseDataLake::dropTablereplays on its fresh instance.Data and delete files from the manifests are deleted first, then the catalog entry (Glue), then the metadata, so a failed DROP stays retryable. REST catalogs (S3 Tables too) and Unity are asked to purge instead; Unity refuses a setting contradicting the table's managed/external type, and Hive cannot drop tables, both before anything is deleted. Known residuals: a DROP failing midway is not atomic, so a Glue table, or an Atomic one restored by
UNDROPduring the retry, can miss deleted files; a table not read sinceATTACHdeletes the table currently at its path, the one itsSELECTreads; and a restart before an Atomic database's delayed drop keeps the files, as before.Tests:
04365(setting on and off, re-create, leftover version hint, a table inside its directory, a new table or another table's metadata at the path, a table not read sinceATTACH) and04366(failure handling, also with Avro data and on a retry) fail without the fix.test_database_iceberg(two tables at one location too),test_database_glueandtest_database_unity_v2cover catalogs.Workflow [PR]
Sync PR [sync-upstream/pr/109071]