iceberg icon indicating copy to clipboard operation
iceberg copied to clipboard

Deleting metadata(expire_snapshots doesn't help...)

Open atomsis opened this issue 2 years ago • 4 comments

Query engine

I am working with Trina Iceberg connector

Question

It does not have vacuum which, if I am not mistaken, solves my problem. I had a task to optimize packages (I used optimize - everything is ok with it, it works as it should). And also it is necessary to delete old snapshots (for example, older than 7 days) - I used expire_snapshots - the documentation says that it deletes both old snapshots and metadata from them - but not only does it not delete metadata - it seems to not delete regular snapshots either. Then I decided to use remove_orphan_files. It works better - but does not delete metadata - but does as I want = deletes snapshots older than a certain period. Another small clarification: remove_orphan_files worked and then began to work every other time, I added commands in a row: first expire_snapshots and then remove_orphan_files - and now it consistently cleans old snapshots, but not metadata, although it seems that expire_snapshots should. Help me with any ideas (I apologize for my English)

atomsis avatar Sep 19 '24 11:09 atomsis

This issue has been automatically marked as stale because it has been open for 180 days with no activity. It will be closed in next 14 days if no further activity occurs. To permanently prevent this issue from being considered stale, add the label 'not-stale', but commenting on the issue is preferred when possible.

github-actions[bot] avatar Mar 19 '25 00:03 github-actions[bot]

I also wonder whether metadata files are cleared correctly. This is my test scenario:

  1. create table
create table op_test.test_entity (
    created_at timestamp(6) with time zone,
    id bigint,
    data bigint
) with (
    format = 'PARQUET',
    format_version = 2,
    location = 's3://warehouse/op_test/test_entity',
    partitioning = ARRAY['day(created_at)'],
    sorted_by = ARRAY['created_at']
);

select committed_at, snapshot_id, parent_id, operation, manifest_list from op_test."test_entity$snapshots";
committed_at snapshot_id parent_id operation manifest_list
2025-03-24 09:41:52.653 +00:00 1552900420629541478 null append s3://warehouse/op_test/test_entity/metadata/snap-1552900420629541478-1-aa0615f9-5b78-457c-af13-1111de39f8ff.avro
  1. inserting data

select committed_at, snapshot_id, parent_id, operation, manifest_list from op_test."test_entity$snapshots";
committed_at snapshot_id parent_id operation manifest_list
2025-03-24 09:41:52.653 +00:00 1552900420629541478 null append s3://warehouse/op_test/test_entity/metadata/snap-1552900420629541478-1-aa0615f9-5b78-457c-af13-1111de39f8ff.avro
2025-03-24 11:16:54.788 +00:00 7610639897136105147 1552900420629541478 append s3://warehouse/op_test/test_entity/metadata/snap-7610639897136105147-1-1402cc0a-723b-4fa6-893e-276204d4792c.avro
  1. updating the data
update op_test.test_entity set data = 2 where id = 1;

select committed_at, snapshot_id, parent_id, operation, manifest_list from op_test."test_entity$snapshots";
committed_at snapshot_id parent_id operation manifest_list
2025-03-24 09:41:52.653 +00:00 1552900420629541478 null append s3://warehouse/op_test/test_entity/metadata/snap-1552900420629541478-1-aa0615f9-5b78-457c-af13-1111de39f8ff.avro
2025-03-24 11:16:54.788 +00:00 7610639897136105147 1552900420629541478 append s3://warehouse/op_test/test_entity/metadata/snap-7610639897136105147-1-1402cc0a-723b-4fa6-893e-276204d4792c.avro
2025-03-24 11:18:20.124 +00:00 1067091930589353459 7610639897136105147 overwrite s3://warehouse/op_test/test_entity/metadata/snap-1067091930589353459-1-5b3f30dc-37a0-4288-af2d-c579c1aa2878.avro

The metadata files in s3:

Image
  1. Running manifest/snapshot optimizations
SET SESSION rest_backend.expire_snapshots_min_retention = '1s';
SET SESSION rest_backend.remove_orphan_files_min_retention = '1s';
ALTER TABLE op_test.test_entity EXECUTE optimize_manifests;
ALTER TABLE op_test.test_entity EXECUTE expire_snapshots(retention_threshold => '1s');
ALTER TABLE op_test.test_entity EXECUTE remove_orphan_files(retention_threshold => '1s');

select committed_at, snapshot_id, parent_id, operation, manifest_list from op_test."test_entity$snapshots";
committed_at snapshot_id parent_id operation manifest_list
2025-03-24 11:23:28.763 +00:00 1944591329871905239 1067091930589353459 replace s3://warehouse/op_test/test_entity/metadata/snap-1944591329871905239-1-af49462f-ede6-4ce8-9c0e-9f4e2d3ad88f.avro

new snapshot was created, all other removed - so far so good. But looking at the files in s3:

Image

we can see snapshot files removed (eg snap-155....avro), but the metadata.json (eg 00000-210fd671-e520-42e7-90eb-bf26664b2fda.metadata.json) is still there. When opening this json, it has only one snapshot - 1552900420629541478 - the one removed. Shouldn't this metadata.json also be removed?

b4sus avatar Mar 24 '25 11:03 b4sus

This issue has been automatically marked as stale because it has been open for 180 days with no activity. It will be closed in next 14 days if no further activity occurs. To permanently prevent this issue from being considered stale, add the label 'not-stale', but commenting on the issue is preferred when possible.

github-actions[bot] avatar Sep 21 '25 00:09 github-actions[bot]

This issue has been closed because it has not received any activity in the last 14 days since being marked as 'stale'

github-actions[bot] avatar Oct 05 '25 00:10 github-actions[bot]