-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Don't delete files when commit to hive metastore fails #12209
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,21 +88,15 @@ protected void commitToExistingTable(TableMetadata base, TableMetadata metadata) | |
| .setParameter(METADATA_LOCATION_PROP, newMetadataLocation) | ||
| .setParameter(PREVIOUS_METADATA_LOCATION_PROP, currentMetadataLocation) | ||
| .build(); | ||
|
|
||
| // todo privileges should not be replaced for an alter | ||
| PrincipalPrivileges privileges = table.getOwner().map(MetastoreUtil::buildInitialPrivilegeSet).orElse(NO_PRIVILEGES); | ||
| metastore.replaceTable(database, tableName, table, privileges); | ||
| } | ||
| catch (RuntimeException e) { | ||
| try { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As per apache/iceberg#2317
This implementation never deletes the new metadata file. Is this intentional? See https://github.com/apache/iceberg/pull/2328/files#diff-e502621d52f86cf0ec3187dda30ac61f6b76efb7b6276bc8d233ccb2c836fb98R482 where the metadata is deleted only in case of
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is intentional, we do have a little different logic than iceberg library so it can't be copied one to one, also it is safer not to ever delete these files. |
||
| io().deleteFile(newMetadataLocation); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This usecase is probably pretty exotic to catch in a real-world test case.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can try to unit test this but in my opinion it wouldn't be very useful, also although code here is pretty simple it would require a lot of mocking and it is only a little part of whole commit process that is initiated in
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
further, we should have a comment saying that we can introduce error categorization to know when such cleanup would be safe after the mutating call first. We don't need to introduce the categorization in this PR.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interestingly, @alexjo2144 intentional?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I took them out based on this comment from David #10845 (comment)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I aired on the side of, not cleaning up is safe and figuring out which situations are safe is hard. So leave it for
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @findepi so what should I do? add deletion here and in Glue for the case when
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's do what Alex did for Glue -- leave behind |
||
| } | ||
| catch (RuntimeException ex) { | ||
| e.addSuppressed(ex); | ||
| } | ||
| // CommitFailedException is handled as a special case in the Iceberg library. This commit will automatically retry | ||
| throw new CommitFailedException(e, "Failed to commit to table %s.%s", database, tableName); | ||
| } | ||
|
|
||
| // todo privileges should not be replaced for an alter | ||
| PrincipalPrivileges privileges = table.getOwner().map(MetastoreUtil::buildInitialPrivilegeSet).orElse(NO_PRIVILEGES); | ||
| metastore.replaceTable(database, tableName, table, privileges); | ||
| } | ||
| finally { | ||
| thriftMetastore.releaseTableLock(identity, lockId); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.