-
Notifications
You must be signed in to change notification settings - Fork 3k
delete file by mistake when rewriting iceberg table throw CommitStateUnknownException #2932
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
delete file by mistake when rewriting iceberg table throw CommitStateUnknownException #2932
Conversation
core/src/main/java/org/apache/iceberg/actions/BaseRewriteDataFilesAction.java
Show resolved
Hide resolved
stevenzwu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left one minor comment
|
cc @stevenzwu @openinx @rdblue
thanks for your concern, it's ready for review |
| return new RewriteDataFilesActionResult(currentDataFiles, addedDataFiles); | ||
| } | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove unnecessary changes like this and reformatting lines that don't need to change. We avoid changes that aren't required to avoid git commit conflicts.
|
This looks valid to me. The action will clean up data files for any exception, but we should not do that when the commit state is unknown. FYI @RussellSpitzer. @wg1026688210, can you remove any unnecessary formatting and whitespace changes? It would also be great to update the description with the case that this fixes. Thanks for working on this! |
|
Yeah this is definitely the right thing to do, we are handling this in the new code ( iceberg/core/src/main/java/org/apache/iceberg/actions/RewriteDataFilesCommitManager.java Lines 97 to 109 in a1bd63d
|
ok |
looking forward to using the new version rewrite |
| long startingSnapshotId) { | ||
| private void replaceDataFiles( | ||
| Iterable<DataFile> deletedDataFiles, Iterable<DataFile> addedDataFiles, | ||
| long startingSnapshotId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wg1026688210, please remove changes like this that are unnecessary.
| .onFailure((location, exc) -> LOG.warn("Failed to delete: {}", location, exc)) | ||
| .run(fileIO::deleteFile); | ||
| if (e instanceof CommitStateUnknownException) { | ||
| LOG.warn("for unknown commiting state ,we should not delete file "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please copy the other warning messages here. This needs to conform more to the error message expectations that we use:
- Messages should use sentence case
- Messages should not end in whitespace
- Do not use personal pronouns
- Be clear about what happened and what action is being taken
This should be something more like "Skipping commit cleanup: commit state is unknown". But check the other places where we catch CommitStateUnknownException and use a similar message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, learned a lot for me
| .suppressFailureWhenFinished() | ||
| .onFailure((location, exc) -> LOG.warn("Failed to delete: {}", location, exc)) | ||
| .run(fileIO::deleteFile); | ||
| if (e instanceof CommitStateUnknownException) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this not a separate catch block? I think it should be a catch instead of using instanceof.
2.Remove redundant code format
| doReplace(deletedDataFiles, addedDataFiles, startingSnapshotId); | ||
| } catch (CommitStateUnknownException e) { | ||
| LOG.warn("Commit state unknown for files: {}, cannot clean up files because they may have been committed " + | ||
| "successfully.", Lists.newArrayList(addedDataFiles), e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove the list of data files from logs. That is going to be too long. Instead, let's use "Commit state unknown, cannot clean up files that may have been committed"
| "successfully.", Lists.newArrayList(addedDataFiles), e); | ||
| throw e; | ||
| } catch (Exception e) { | ||
| LOG.warn("Failed to rewrite, files {} will be delete", Lists.newArrayList(addedDataFiles)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove the file list here as well. Instead, use "Failed to commit rewrite, cleaning up rewritten files"
|
Hi,@rdblue @RussellSpitzer .the pr appears conflicts. Do we need to maintain the rewrite api of old version next release. If necessary, I will resolve this conflict. |
|
I'll defer to @RussellSpitzer on whether we should fix the old API. |
|
Sorry for taking so long to get to this, I think this would be worth keeping just because of how difficult it is to deal with this situation. Please update the PR and I will merge it in. |
…elete_file_by_mistake � Conflicts: � spark/src/test/java/org/apache/iceberg/actions/TestRewriteDataFilesAction.java
|
Ok, I will resolve this conflict today |
hi~ @RussellSpitzer the conflict has been resolved |
RussellSpitzer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
This pr is to solve the problem of deleting files by mistake in rewriting table if we can’t judge whether the submission is successful when commiting.
The solution is that we only print some logs and do not clean up the files if throw CommitStateUnknownException when commiting ,leave the cleanup work to RemoveOrphanFiles