Skip to content

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

Description

@wombatu-kun

Search before asking

  • I searched in the issues and found nothing similar.

Paimon version

master, 142f823

Compute Engine

Engine independent, format tables.

Minimal reproduce step

Found by code inspection rather than from a failing job. Make a format writer throw an unchecked exception out of close(); several format writers wrap IO failures in RuntimeException or UncheckedIOException.

What doesn't meet your expectations?

FormatTableSingleFileWriter.close() routes only IOException to the cleanup path:

try {
    if (writer != null) {
        writer.close();
        writer = null;
    }
    if (out != null) {
        out.flush();
        outputBytes = out.getPos();
        committer = ((TwoPhaseOutputStream) out).closeForCommit();
        out = null;
    }
} catch (IOException e) {
    LOG.warn("Exception occurs when closing file {}. Cleaning up.", path, e);
    abort();
    throw e;
} finally {
    closed = true;
}

An unchecked throw out of writer.close() skips abort() entirely, so out is left open and the data staged for the two phase commit is never discarded. The finally block then sets closed = true, so a later close() returns at the top of the method and nothing else will clean up.

Note that abort() itself is written defensively, catching Throwable around both the closeForCommit and the discard calls. The problem is only that it never runs.

Anything else?

Fix shape: widen the catch around the cleanup decision to Throwable, keeping the existing rethrow behaviour for IOException.

Reported alongside two stream leak reports found in the same pass while reviewing #8962.

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions