apache/iceberg · error · UncheckedIOException
Failed to close dvFileWriter
Error message
Failed to close dvFileWriter
What it means
BaseTaskWriter's close() closes its internal delete-vector file writer and rethrows any IOException as UncheckedIOException. This surfaces an I/O failure (flush/close to the underlying OutputFile) that happened while finalizing delete-vector files during task completion or abort.
Source
Thrown at core/src/main/java/org/apache/iceberg/io/BaseTaskWriter.java:174
.build();
}
@Override
public void close() throws IOException {
try {
if (dvFileWriter != null) {
try {
// complete will call close
dvFileWriter.close();
DeleteWriteResult result = dvFileWriter.result();
completedDeleteFiles.addAll(result.deleteFiles());
referencedDataFiles.addAll(result.referencedDataFiles());
} finally {
dvFileWriter = null;
}
}
} catch (IOException e) {
throw new UncheckedIOException("Failed to close dvFileWriter", e);
}
}
/** Base equality delta writer to write both insert records and equality-deletes. */
protected abstract class BaseEqualityDeltaWriter implements Closeable {
private final StructProjection structProjection;
private final PositionDelete<T> positionDelete;
private final StructLike partitionKey;
private RollingFileWriter dataWriter;
private RollingEqDeleteWriter eqDeleteWriter;
private PartitioningWriter<PositionDelete<T>, DeleteWriteResult> posDeleteWriter;
private Map<StructLike, PathOffset> insertedRowMap;
private boolean closePosDeleteWriter;
protected BaseEqualityDeltaWriter(StructLike partition, Schema schema, Schema deleteSchema) {
this(partition, schema, deleteSchema, DeleteGranularity.PARTITION, null);
}
View on GitHub (pinned to 86d9c8fc54)
Solutions
- Inspect the cause chain (getCause()) for the underlying IOException and fix that root cause in the FileIO or filesystem.
- Ensure the task writer is closed exactly once and not after its output streams were independently closed.
- Verify the OutputFile location is writable and the FileIO is not already closed when the task writer completes.
Example fix
// before FileIO io = ...; io.close(); writer.close(); // IO closed before writer // after writer.close(); // finalize writers first io.close();
Defensive patterns
Strategy: try-catch
Try / catch
try {
taskWriter.close();
} catch (UncheckedIOException e) {
LOG.error("DV writer close failed", e.getCause());
throw e; // task must fail; fix underlying FileIO
} Prevention
- Close task writers before closing the FileIO they use.
- Inspect the IOException cause chain to find the real filesystem failure.
- Ensure output locations are writable and streams are not double-closed.
When it happens
Trigger: An IOException occurs while closing the DV writer, typically from the underlying OutputFile/stream failing (closed stream, IO provider error, disk/FS error in wrapped FileIO) during complete() or abort().
Common situations: Underlying FileIO throwing on close (e.g., mocked InMemory IO closed prematurely, network file systems failing during final flush); closing the task writer twice or after the output stream was already closed elsewhere in custom writer code.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- Failed to close manifest reader
- Failed to close entries while caching changes
- Failed to close
- Failed to close current writer
- Failed to write delete manifests
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/ad4870910d8f2a63.
Report an issue: GitHub.