-
Notifications
You must be signed in to change notification settings - Fork 3k
Core: Fix exception handling in BaseTaskWriter #5683
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
Conversation
| if (!closed) { | ||
| flushDeletes(); | ||
| this.closed = true; | ||
| flushDeletes(); |
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.
Fixes double close here as well.
| public List<DeleteFile> complete() throws IOException { | ||
| close(); | ||
|
|
||
| Preconditions.checkState(failure != null, "Cannot return results from failed writer", failure); |
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.
This implements the same logic as in BaseTaskWriter: if there was an exception while writing the file, don't allow complete to succeed.
* Core: Fix exception handling in BaseTaskWriter. * Fix state check.
* Core: Fix exception handling in BaseTaskWriter. * Fix state check.
* Core: Fix exception handling in BaseTaskWriter. * Fix state check.
* Core: Fix exception handling in BaseTaskWriter. * Fix state check.
* Core: Fix exception handling in BaseTaskWriter. * Fix state check.
This is an alternative fix for the Flink double close problem, #4168 and #5310.
The original solution modified
S3OutputStreamso that every call tocloseafter a failure would re-throw the original exception. That violates the contract forclose, which states:The original fix also did not address the underlying problem that the stream was closed twice and still emitting data files. This PR fixes double close cases in
BaseTaskWriterby ensuring the writer that is closed is always set to null.This PR also attempts to fix the problem of duplicate data in Flink by throwing an
IllegalStateExceptionif a call toclosefails butcompleteis still called on theBaseTaskWriter. The write result fromcompleteis the only way to emit data files, so this ensures that no data files will be emitted from a writer that failed while closing a file. This is a precaution because it isn't clear why failed Flink writers were still emitting data files.