Skip to content

Core: Broaden exception handling in writer clean up logic - #12863

Merged
amogh-jahagirdar merged 1 commit into
apache:mainfrom
xiaoxuandev:broaden-exception-handling-for-write
May 1, 2025
Merged

amogh-jahagirdar merged 1 commit into
apache:mainfrom
xiaoxuandev:broaden-exception-handling-for-write

Conversation

@xiaoxuandev

@xiaoxuandev xiaoxuandev commented Apr 21, 2025 •

Copy link
Copy Markdown
Contributor

Expanded the exception handling during writer cleanup to address scenarios where users may lack delete permissions, ensuring consistent behavior with uncommitted file deletion handling.

@github-actions github-actions Bot added the core label Apr 21, 2025
@xiaoxuandev
xiaoxuandev force-pushed the broaden-exception-handling-for-write branch from c1aae7c to 64cee91 Compare April 21, 2025 21:02
} catch (UncheckedIOException e) {
// the file may not have been created, and it isn't worth failing the job to clean up,
// skip deleting
} catch (RuntimeException e) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This catch is pretty broad what do you think about including some log message here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review! I was trying to keep the same behavior, but I don’t mind adding a log message if people think it would be helpful and not cause confusion.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @xiaoxuandev @geruh . I generally agree with the change, since regardless of the type of failure here, it should not blow up the overall write being performed since this is just a best effort cleanup. I also agree with a warn log.

My only ask is we follow the same pattern like we do in other places and just use Tasks to express this.

Check out https://github.com/apache/iceberg/blob/main/core/src/main/java/org/apache/iceberg/BaseTransaction.java#L485 , which essentially has the same best effort cleanup that we want.

@amogh-jahagirdar amogh-jahagirdar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @xiaoxuandev , overall the premise of this change makes sense to me, just had a comment about using Tasks like we do in other places where best effort cleanup is performed

} catch (UncheckedIOException e) {
// the file may not have been created, and it isn't worth failing the job to clean up,
// skip deleting
} catch (RuntimeException e) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @xiaoxuandev @geruh . I generally agree with the change, since regardless of the type of failure here, it should not blow up the overall write being performed since this is just a best effort cleanup. I also agree with a warn log.

My only ask is we follow the same pattern like we do in other places and just use Tasks to express this.

Check out https://github.com/apache/iceberg/blob/main/core/src/main/java/org/apache/iceberg/BaseTransaction.java#L485 , which essentially has the same best effort cleanup that we want.

@xiaoxuandev
xiaoxuandev force-pushed the broaden-exception-handling-for-write branch from 64cee91 to de9907d Compare April 30, 2025 18:11
@xiaoxuandev

Copy link
Copy Markdown
Contributor Author

Thanks @amogh-jahagirdar for the review! I’ve updated the change to follow the same cleanup approach, could you help take another look?

@amogh-jahagirdar amogh-jahagirdar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @xiaoxuandev , just a nit but non-blocking. I'll leave it up until tomorrow morning, for others to review and then I'll go ahead and merge if there are no objections!

.onFailure(
(file, exc) ->
LOG.warn(
"Failed to delete the empty file during writer clean up: {}",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Not sure the fact that it's an empty file is really useful in the log (maybe, as a user if you see the warn log that it's empty you're less concerned about how much dangling storage is there). I'd probably leave the "the empty" out but I'm also OK with it as it is since it's probably such a rare case that the log will be fired off.

@amogh-jahagirdar amogh-jahagirdar Apr 30, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Or if we want to say "empty" to avoid user confusion on what's attempted to be deleted in the logs, I'd actually go a step further and say "uncommitted empty file". The uncommitted part is actually important to indicate to a user that we're not deleting anything that's part of their table.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point! Calling it an "uncommitted empty file" makes it much clearer and avoids confusion, updated.

@xiaoxuandev
xiaoxuandev force-pushed the broaden-exception-handling-for-write branch from de9907d to b571ced Compare April 30, 2025 21:13
@amogh-jahagirdar

Copy link
Copy Markdown
Contributor

Thanks @xiaoxuandev and thanks @geruh for reviewing, I'll go ahead and merge

@amogh-jahagirdar
amogh-jahagirdar merged commit bea3f8b into apache:main May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants