Repository navigation
Conversation
…redentials refresh - `remove_orphan_files`: every file reachable from any snapshot survives `older_than` = now (format versions 2 and 3, position deletes, time travel), `older_than` boundaries and session time zone, a file from a writer with a skewed clock, idempotent re-runs, 1000 orphans, `ALTER TABLE EXECUTE` grant. - `expire_snapshots`: deleted rows stay deleted, file-statistics answers match a full read, time travel to an expired snapshot fails, a second table over the same path never returns missing rows, files whose deletion was lost are collected as orphans, 100 snapshots. - Maintenance racing an INSERT paused before its commit (`iceberg_writes_pause_before_commit`). - `timestamp_ns` / `timestamptz_ns` tables written by Java Iceberg (committed fixture with its generator): values keep every nanosecond, and partition, manifest-list and Parquet pruning never change a result for unpartitioned, identity, day, hour and bucket specs. - Spark-written tables (v2 position deletes, v3 deletion vectors, `rewrite_data_files`, `compute_table_stats`) after ClickHouse `expire_snapshots` and `remove_orphan_files`: Spark and `icebergS3Cluster` read the same rows. - Unity catalog: an expired vended token during a scan is refreshed through the catalog, and a database recovers after the catalog vended bad credentials (v1 and v2). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [2c7d03d] Summary: ❌
AI ReviewSummaryThe PR adds Iceberg maintenance, nanosecond timestamp, interoperability, and vended-credential tests. Request changes: the Azure E2E test requires behavior already fixed on master, and seven existing findings about incomplete assertions remain applicable at PR head Findings
Missing context / blind spots
Final VerdictStatus: Update the Azure expectations, add the missing denied-access assertion, and verify actual storage contents in the affected maintenance and failed-insert tests. Seven existing threads need no additional reply; the Azure expectation failure is the only new inline finding. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d 3, fuzzing and credentials - `test_e2e_iceberg_engine`: `expire_snapshots` and `remove_orphan_files` on real S3 and Azure, with delete/list `ProfileEvents` bounds from `query_log`, and pyiceberg reading the S3 table back. - `05371_iceberg_maintenance_fuzzer`: seeded random writes and maintenance checked after every step against a `MergeTree` mirror, for format versions 2 and 3. - 05367 and 05368 also run on format version 3. - `test_maintenance_spark_tables`: Azure, and `remove_orphan_files` with read-only credentials reports `failed_deletions_count` and deletes nothing. - `test_database_unity_v2`: vended credentials rotated between queries to another MinIO user (the old one disabled), and an INSERT with read-only vended credentials commits nothing. - `test_database_iceberg`: `EXECUTE` through a catalog database needs `ALTER TABLE EXECUTE`. - `helpers/s3_tools.py`: `minio_user` creates a MinIO user with a given policy and removes it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- `test_e2e_catalogs`: `expire_snapshots` and `remove_orphan_files` through a Glue `DataLakeCatalog` on real S3; Glue points at ClickHouse's new metadata and pyiceberg reads it back. - 05367: with 100 snapshots and the metadata cache off, both commands open at most 4 files per snapshot, which catches quadratic work. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Spark SQL needs `count(*)`. - 05367 and 05371 were too slow under MSan: 30 snapshots in the cost bound, one seed and 20 steps in the fuzzer (now tagged `long`). - `expire_snapshots` must also delete v3 deletion vectors. - The refresh test uses the same query for the baseline and checks `ReadBufferFromS3RequestsErrors`, so the expired-token path is known to have run. - The E2E test checks the "No snapshot found" message. - The MinIO policy names object ARNs explicitly. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125329&sha=9d30f121d3134ca5b04d2276140b02510000b724&name_0=PR Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rsion maintenance - `test_database_unity_v2`: vended credentials rotated to another MinIO user while a SELECT is paused between chunks (`object_storage_source_pause_before_virtual_columns`); the query refreshes them and returns every row. - `test_e2e_catalogs`: `expire_snapshots` and `remove_orphan_files` on a table ClickHouse writes to real GCS through a named collection with Google OAuth credentials. - `test_backward_compatibility/test_iceberg_maintenance`: a table written and maintained by 26.3 is read and maintained by the current build, and the other way round. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
|
||
| node.query(f"GRANT ALTER TABLE EXECUTE ON {CATALOG_NAME}.* TO {user}") | ||
| node.query(expire_query, settings=settings, user=user) | ||
| node.query(f"ALTER TABLE {table_ref} EXECUTE remove_orphan_files(dry_run = 1)", settings=settings, user=user) |
There was a problem hiding this comment.
This only proves the denied path for expire_snapshots. The catalog entrypoint for ALTER TABLE ... EXECUTE remove_orphan_files is different enough that a privilege bypass there would still pass: the test calls remove_orphan_files only after granting ALTER TABLE EXECUTE.
Since this PR explicitly claims that remove_orphan_files also needs that grant through a catalog database, could you add the pre-grant ACCESS_DENIED assertion for remove_orphan_files(dry_run = 1) too?
| assert read_only_secret not in error | ||
|
|
||
| assert node.query(f"SELECT * FROM {table}") == "1\ta\n" | ||
| assert delta_log() == commits |
There was a problem hiding this comment.
Comparing only _delta_log/ misses the failure mode we already had in tests/integration/test_storage_delta/test.py: a failed Delta INSERT can leak orphan Parquet data files outside the log.
If this path uploads a data file with cached old write credentials and only fails later, delta_log() == commits and SELECT * still pass while the table prefix accumulates garbage. Please snapshot/list the whole table prefix and assert that no non-_delta_log *.parquet appears after the failing INSERT, so this really covers “commits nothing” rather than only “no new commit”.
| # A metadata file of ClickHouse's own commit is missing from `metadata-log`: | ||
| # https://github.com/ClickHouse/ClickHouse/issues/118812 | ||
| removed.pop("deleted_metadata_files_count", None) | ||
| assert removed == {"deleted_data_files_count": 1} |
There was a problem hiding this comment.
This only trusts ClickHouse’s returned metrics. Unlike the S3/Azure/Glue variants, the GCS branch never checks that orphan-{suffix}.parquet actually disappears from storage, so a backend bug that increments deleted_data_files_count but leaves the object in GCS would still pass here.
Could you verify that the planted object is gone (for example via a small helper on catalog_manager / gcsfs), and optionally mirror the query-log delete/list bound that the other backends already assert?
… after a newer writer - 05369 checks all predicates of a table in one client call per pruning mode instead of one call per predicate. - 05366 builds its scale table from 2 inserts over 50 partitions with 200 orphans. - The cross-version test no longer appends from 26.3 after the current build wrote the table: 26.3 copies newer manifest-list entries unconverted and corrupts the table. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125329&sha=6900d40bac012607498c36ca20e3c20cc33abfb1&name_0=PR Co-Authored-By: Claude Opus 5.5 <[email protected]>
| removed = metrics(instance, table, f"remove_orphan_files(older_than = '{cutoff}')") | ||
| # metadata.json files are left out: ClickHouse's own commit may leave one out of metadata-log. | ||
| removed.pop("deleted_metadata_files_count") | ||
| assert {name: value for name, value in removed.items() if value} == {"deleted_data_files_count": 1} |
There was a problem hiding this comment.
This still only trusts the counters returned by remove_orphan_files. The later Spark/readback checks ignore extra unreferenced objects, so a regression that leaks orphan.parquet while still reporting deleted_data_files_count = 1 would pass on all three backends.
Please also check the exact orphan path after the ALTER (stat_object, get_blob_client(...).exists(), or a local test -e) so the test proves the file actually disappears.
| # Metadata files are not checked: https://github.com/ClickHouse/ClickHouse/issues/118812 | ||
| removed.pop("deleted_metadata_files_count", None) | ||
| # Only the planted file goes: nothing written by the old version is taken for an orphan. | ||
| assert removed == {"deleted_data_files_count": "1"} |
There was a problem hiding this comment.
This only asserts the metrics returned by remove_orphan_files. If the cross-version path regresses into a no-op (or reports a deletion without actually removing the object), the final SELECT still passes because the planted orphan is never read.
Since the contract here is “only the planted file goes”, please also verify that orphan is gone from MinIO after the ALTER (for example by expecting stat_object to fail). That makes the test prove both halves: the real orphan was deleted, and the old-version files were preserved.
- `test_maintenance_on_spark_table`: Spark keeps v2 position delete files live after `rewrite_data_files` unless `remove-dangling-deletes` is set. - `test_engine_expire_snapshots_and_remove_orphan_files`: remove orphans before ClickHouse's first commit; after it the table mixes `vN.metadata.json` with pyiceberg's file names and maintenance refuses to run. - 05369 is tagged `long`: under ASan with S3 storage each of its table reads takes seconds. - Link ClickHouse#125399 from the cross-version test. CI report: https://d1k2gkhrlfqv31.cloudfront.net/clickhouse-test-reports-private/praktika.html?PR=80850&sha=354f42a71df7300b62730d8da4c4f04e6462006d&name_0=PR Related: ClickHouse/clickhouse-private#80850 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Spark keeps them live after rewrite_data_files: the rewritten files keep the sequence number of the delete. Only v3 deletion vectors go away with the rewritten data files. Also link ClickHouse#125431 from the E2E maintenance test. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125329&sha=a1248abd78574d87dfe4889f7d8cf63ba5113e63&name_0=PR Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
| query_id=query_id, | ||
| ) | ||
| ) | ||
| assert removed == {"deleted_data_files_count": 1} |
There was a problem hiding this comment.
This still only trusts ClickHouse’s returned counters. The later SELECT and load_stored_table checks ignore extra objects, so a regression that leaves the planted orphan in storage — or leaks the data / manifest objects that only expired snapshots used — would still pass here as long as the metadata was updated and the metrics said 1.
Could we assert the backend state directly (for example, the exact orphan path is gone after remove_orphan_files, and the expired-only object set is gone after expire_snapshots)?
… test With a hierarchical namespace, Azure lists directories too and remove_orphan_files fails to delete them: ClickHouse#125462 CI report: https://d1k2gkhrlfqv31.cloudfront.net/clickhouse-test-reports-private/praktika.html?PR=80850&sha=0a83645f51a151d0501276762a64d88b2f1c5037&name_0=PR Related: ClickHouse/clickhouse-private#80850 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
In a `Replicated` database `ALTER TABLE ... EXECUTE` goes through distributed DDL and does not return the command's result rows, so the `deleted_*_count` lines are missing. Same tag as `03978_alter_table_execute_expire_snapshots_parse`. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125329&sha=9fc8ffd8c1443f05c7a610cc1d1cc6ab630ac67a&name_0=PR ClickHouse#125329 Co-Authored-By: Claude Opus 5.5 <[email protected]>
| spark.sql(f"CALL spark_catalog.system.compute_table_stats(table => 'default.{table}')") | ||
| expected = spark.sql(f"SELECT count(*), sum(id) FROM {table}").first() | ||
|
|
||
| default_upload_directory(cluster, storage_type, f"/iceberg_data/default/{table}/", f"/iceberg_data/default/{table}/") |
There was a problem hiding this comment.
This expire_snapshots half still only trusts the returned counters. The later REFRESH TABLE / snapshot-id failure checks prove the metadata moved on, but they do not prove the expired-only data or delete files actually disappeared from storage: Spark ignores extra unreferenced objects under the table prefix.
That means a regression that leaks the rewritten files (or v2/v3 delete files) while still reporting a positive deleted_* count would still pass here. Could you snapshot the object set before expire_snapshots and assert that the files reachable only from expired snapshots are gone afterward, not just that the current snapshot stays readable?
ClickHouse#125376 rejects a `remove_orphan_files` `older_than` less than `iceberg_orphan_files_min_retention_seconds` (default 1 day) before now. These tests plant fresh orphans and use a recent `older_than` on purpose, so they set it to 0, as that PR does for the existing tests. 05368 keeps the default window. The in-flight INSERT with a recent `older_than` is covered by `05372_iceberg_remove_orphan_files_min_retention` from that PR. ClickHouse#125329 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The merge queue run failed on two tests of this PR: - `test_backward_compatibility/test_iceberg_maintenance`: master renamed the setting to `allow_expire_snapshots` and kept `allow_experimental_expire_snapshots` as an alias. The client resolves the alias and sends the new name, which a 26.3 server ignores, so `expire_snapshots` on the old node failed with `SUPPORT_IS_DISABLED`. Pass the old name in the query `SETTINGS` clause, which the server resolves itself. - `05367_iceberg_expire_snapshots_reachability`: `remove_orphan_files` keeps files modified in the second of `older_than` or later. The restored files kept their original modification time, which can fall in the same second as the cutoff, so some were not collected. Backdate the restored files. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=gh-readonly-queue/master/pr-125329-841a49bef228ca732259b59363ceb93b4a002323&sha=510152fd6c5426e817ce24a8599c6683ce8e7399&name_0=MergeQueueCI ClickHouse#125329 Co-Authored-By: Claude Opus 5.5 <[email protected]>
| failed = removed.pop("failed_deletions_count") if is_azure else 0 | ||
| # The `data` and `metadata` directories, and nothing else. | ||
| assert failed == (2 if is_azure else 0) |
There was a problem hiding this comment.
[Major] Update the Azure expectations after the directory-listing fix
#125500 is merged, and AzureObjectStorage::listObjects now skips the directory entries that caused #125462. A successful cleanup therefore reports failed_deletions_count = 0. _nonzero_metrics removes that field, so this pop raises KeyError on the Azure backend; the following assertion also still requires the old two failures.
Remove the directory-failure workaround and expect only the planted orphan to be deleted, with no failed deletions and one AzureDeleteObjects request.
Tests for Iceberg maintenance and advanced reads, focused on not losing data and not returning wrong results:
remove_orphan_fileskeeps every file reachable from any snapshot even witholder_than= now (v2 and v3), handles theolder_thanboundary, session time zone and clock-skewed files, is idempotent, scales to 1000 orphans, and needs theALTER TABLE EXECUTEgrant.expire_snapshotskeeps deleted rows deleted, keeps file-statistics answers right, makes time travel to an expired snapshot fail loudly, never makes a second table over the same path return missing rows, and leaves files whose deletion was lost toremove_orphan_files.timestamp_ns/timestamptz_nstables written by Java Iceberg (small committed fixture plus its generator): exact nanoseconds, and pruning never changes a result for identity, day, hour and bucket partitioning. The bucket case skips pre-1970 sub-microsecond values, whereicebergBuckettruncates instead of flooring (Iceberg bucket transform truncates timestamp_ns toward zero: partition pruning silently drops pre-1970 rows #125330).rewrite_data_files, statistics) read identically by Spark andicebergS3Clusterafter ClickHouse maintenance.test_e2e_iceberg_engine), through Glue, and on GCS (test_e2e_catalogs), with delete/listProfileEventsbounds fromquery_log. The GCS test has one writer, so it does not prove commit atomicity on GCS.test_backward_compatibility).MergeTreemirror;remove_orphan_fileswith read-only credentials;ALTER TABLE EXECUTEgrant through a catalog database.DELETE/DROP PARTITIONon v3).Stateless tests pass locally; the integration and E2E tests are verified by CI only. Not covered: cancellation of maintenance commands (#125348) and writes outliving vended credentials (#125349).
Related: #99127
Related: #97132
Related: #115879
Related: #125330
Related: #125331
Related: #125332
Related: #125333
Changelog category (leave one):
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/125329]