Skip to content

[core] Abort single file writers on unchecked close failures - #9016

Merged
JingsongLi merged 2 commits into
apache:masterfrom
wombatu-kun:issue/9007-abort-on-unchecked-close
Aug 7, 2026
Merged

[core] Abort single file writers on unchecked close failures#9016
JingsongLi merged 2 commits into
apache:masterfrom
wombatu-kun:issue/9007-abort-on-unchecked-close

Conversation

@wombatu-kun

Copy link
Copy Markdown
Contributor

Purpose

Closes #9007.

close() in SingleFileWriter and FormatTableSingleFileWriter routed only IOException to abort(), so an unchecked failure skipped cleanup entirely. The finally still sets closed = true, so nothing cleans up later either: the output stream stays open and the partially written file is orphaned. writeImpl(), writeRow() and writeBundle() have caught Throwable and called abort() since 2024, only close() was left narrower.

This is on the default path. async-file-write defaults to true, and AsyncPositionOutputStream throws a bare RuntimeException from flush() and close() when the writing thread is interrupted, so cancelling a Flink job can orphan a data file.

abort() is wrapped because FileIO.deleteQuietly only swallows IOException, so an unchecked cleanup failure would otherwise replace the real error. The rolling writers above still catch only IOException and are left for a separate change.

Tests

Six tests in SingleFileWriterTest and FormatTableSingleFileWriterTest: unchecked failure from the format writer's close(), unchecked failure from the stream's flush() (asserting via TraceableFileIO that the stream is released), IOException still reaching the caller unwrapped, and a failing abort() not replacing the original exception. All fail against the unpatched code.

@JingsongLi JingsongLi 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.

+1

@JingsongLi
JingsongLi merged commit fea8bfb into apache:master Aug 7, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] FormatTableSingleFileWriter.close() skips abort() on unchecked exceptions

2 participants