Skip to content

Conversation

@raunaqmorarka
Copy link
Member

@raunaqmorarka raunaqmorarka commented Aug 1, 2025

Description

Improve parallelism in remove_orphan_files procedure

Additional context and related issues

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x) Release notes are required, with the following suggested text:

## Iceberg
* Improve performance of remove_orphan_files procedure. ({issue}`26326`)

@cla-bot cla-bot bot added the cla-signed label Aug 1, 2025
@github-actions github-actions bot added the iceberg Iceberg connector label Aug 1, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves the performance of the remove_orphan_files procedure by introducing parallel file deletion operations and optimizing manifest reading.

  • Adds a dedicated executor service for file delete operations to enable parallel processing
  • Optimizes manifest reading by selecting only the required file_path column
  • Modifies the file deletion logic to submit batches asynchronously rather than blocking on each batch

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

File Description
IcebergMetadataFactory.java Adds injection and initialization of the new file delete executor service
IcebergMetadata.java Implements parallel file deletion logic and optimizes manifest reading
Multiple test files Updates test constructors to include the new executor service parameter

@raunaqmorarka raunaqmorarka requested a review from sopel39 August 1, 2025 20:31
Copy link
Member

@tbaeg tbaeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

fileSystem.deleteFiles(filesToDelete);
filesToDelete.clear();
List<Location> finalFilesToDelete = filesToDelete;
deleteFutures.add(icebergFileDeleteExecutor.submit(() -> deleteFiles(finalFilesToDelete, schemaTableName, fileSystem)));
Copy link
Contributor

@findinpath findinpath Aug 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is worth seeing whether in production use cases the object store provider will choose to return 429 Too Many Requests

Is the filesystem layer being able to cope with backpressure?
I'm looking at https://github.com/trinodb/trino/blob/master/lib/trino-filesystem-s3/src/main/java/io/trino/filesystem/s3/S3FileSystem.java and i don't see any FailSafe logic built-in.

cc @wendigo @ebyhr

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall parallelism is bounded by iceberg.file-delete-threads.
In general, either the SDK or the filesystem layer is expected to handle backoff and retry on throttling errors.

@raunaqmorarka raunaqmorarka merged commit 47237bb into master Aug 3, 2025
45 checks passed
@raunaqmorarka raunaqmorarka deleted the raunaq/delete-executor branch August 3, 2025 07:50
@github-actions github-actions bot added this to the 477 milestone Aug 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed iceberg Iceberg connector

Development

Successfully merging this pull request may close these issues.

6 participants