Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of drop table in iceberg connector #15981

Merged
merged 1 commit into from
Feb 7, 2023

Conversation

krvikash
Copy link
Contributor

@krvikash krvikash commented Feb 6, 2023

Description

While working on Iceberg small files benchmarking. I noticed that the drop table is very slow when the number of files is too large for a table. The main reason for slowness is dropTableData, which deletes the files concurrently when the fileIO is not an instance of SupportsBulkOperations. we can delete files in bulk if fileIO is an instance of SupportsBulkOperations. So implements SupportsBulkOperations instead of FileIO in ForwardingFileIo.java.

I tested it on my local machine. A table with glue metastore containing data files approx 10K took ~26 minutes without this change whereas with this change it only took ~20 seconds.

Release notes

( ) This is not user-visible or 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:

# Section
* Improve performance of drop table in iceberg connector. ({issue}`15981`)

@cla-bot cla-bot bot added the cla-signed label Feb 6, 2023
@krvikash krvikash marked this pull request as ready for review February 6, 2023 04:25
@krvikash krvikash self-assigned this Feb 6, 2023
fileSystem.deleteFiles(pathList.build());
}
catch (IOException e) {
throw new RuntimeException(e);
Copy link
Member

Choose a reason for hiding this comment

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

Throwing RuntimeException is different from the interface's expectation. It would be nice to throw BulkDeletionFailureException or leave a comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BulkDeletionFailureException requires the number of files that failed to delete. Currently fileSystem.deleteFiles does not give such information. I will prepare a PR for the same.

@krvikash krvikash force-pushed the delete-table-s3-bulk branch from d5565c6 to 1f921c2 Compare February 6, 2023 06:10
@findinpath findinpath requested a review from homar February 6, 2023 08:51
Comment on lines 24 to 25
public class BulkOperationsFileIo
extends ForwardingFileIo
Copy link
Member

Choose a reason for hiding this comment

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

I would implement this directly in ForwardingFileIo, not as a subclass.

(that would probably also satisfy https://github.com/trinodb/trino/pull/15981/files#r1097092879, right?)

cc @electrum

fileSystem.deleteFiles(filesToDelete);
}
catch (IOException e) {
// TODO find out the number of files that failed to delete and throw BulkDeletionFailureException
Copy link
Member

Choose a reason for hiding this comment

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

what is org.apache.iceberg.io.BulkDeletionFailureException#numberFailedObjects needed for?

if we don't need it, we can skip having a TODO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SupportsBulkOperations::deleteFiles throws BulkDeletionFailureException exception. BulkDeletionFailureException will be constructed by providing an integer value numberFailedObjects which means the number of files that failed to delete.

Copy link
Member

Choose a reason for hiding this comment

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

SupportsBulkOperations::deleteFiles throws BulkDeletionFailureException exception.

I know.
BTW it can also throw any unckeched exception, obviously.

numberFailedObjects which means the number of files that failed to delete.

I figured this from the name :)
How does Iceberg lib use that information?

@krvikash krvikash force-pushed the delete-table-s3-bulk branch 2 times, most recently from 17b4302 to 30eff29 Compare February 6, 2023 10:06
@krvikash
Copy link
Contributor Author

krvikash commented Feb 6, 2023

Addressed comments.

CI is failing due to a flaky test

2023-02-06T12:27:38.4496953Z tests | 2023-02-06 18:12:38 INFO: FAILURE / io.trino.tests.product.kudu.TestKuduConnectoKerberosSmokeTest.kerberosAuthTicketExpiryTest (Groups: profile_specific_tests, kudu) took 3.3 seconds

#14441


@Override
public void deleteFiles(Iterable<String> pathsToDelete)
throws BulkDeletionFailureException
Copy link
Member

Choose a reason for hiding this comment

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

This isn’t thrown by the method. Should we be using this instead?

Copy link
Member

Choose a reason for hiding this comment

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

we cannot throw BulkDeletionFailureException becauase we cannot fill BulkDeletionFailureException#numberFailedObjects

see #15981 (comment) for more

fileSystem.deleteFiles(filesToDelete);
}
catch (IOException e) {
throw new UncheckedIOException("Failed to delete some or all of files: " + filesToDelete, e);
Copy link
Member

@ebyhr ebyhr Feb 7, 2023

Choose a reason for hiding this comment

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

I don't think including all file paths to the error message is a good idea in case of large deletes. It may include 1,000 files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @ebyhr| @findepi | @electrum , I am proposing a PR #16006 to track the number of files that failed to delete. If #16006 gets approved then we can throw BulkDeletionFailureException over here.

Copy link
Member

Choose a reason for hiding this comment

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

@ebyhr you convinced me, let's not make the message that long. OTOH, it could be problematic if we do not include any paths in the message. It can make identifying problems harder (eg which bucket did we try to access?).
I pushed a change to display only first 5 paths and then ellipsis ....

@findepi findepi force-pushed the delete-table-s3-bulk branch from 659a3b0 to 3310ec6 Compare February 7, 2023 09:29
@findepi findepi merged commit e41c3a7 into trinodb:master Feb 7, 2023
@findepi findepi mentioned this pull request Feb 7, 2023
@krvikash krvikash deleted the delete-table-s3-bulk branch February 7, 2023 17:21
@github-actions github-actions bot added this to the 407 milestone Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants