apache/seatunnel · error · RuntimeException
failed to close arrow stream reader.
Error message
failed to close arrow stream reader.
What it means
ArrowToSeatunnelRowReader.close() releases the Arrow RootAllocator and closes the ArrowStreamReader. If closing the underlying Arrow stream reader raises an IOException, the method wraps it in this RuntimeException with the original IOException as cause. This fires during teardown, so it often masks or follows an earlier read failure.
Source
Thrown at seatunnel-connectors-v2/connector-common/src/main/java/org/apache/seatunnel/connectors/seatunnel/common/source/arrow/reader/ArrowToSeatunnelRowReader.java:333
}
return convertSeatunnelRowValue(dataType.getSqlType(), null, value);
};
}
@Override
public void close() {
try {
if (root != null) {
root.close();
}
if (rootAllocator != null) {
rootAllocator.close();
}
if (arrowStreamReader != null) {
arrowStreamReader.close();
}
} catch (IOException e) {
throw new RuntimeException("failed to close arrow stream reader.", e);
}
}
}
View on GitHub (pinned to cf67b549a7)
Solutions
- Inspect the cause (getCause()) IOException — fix the underlying stream/IO problem (e.g. file truncation, connection drop) rather than treating this as the root error
- Verify the Arrow stream file is complete and readable (check size/checksum) before reading
- Avoid calling close() more than once on the reader; guard with a closed flag
- Ensure the reader is closed only after reads finish or after handling read exceptions so the cause reflects the real failure
Example fix
// before
reader.close(); // throws RuntimeException('failed to close arrow stream reader.')
// after
try {
reader.close();
} catch (RuntimeException e) {
LOG.warn("arrow reader close failed", e.getCause());
} Defensive patterns
Strategy: try-catch
Validate before calling
// verify stream before constructing reader
File f = new File(arrowPath);
if (!f.exists() || f.length() == 0) throw new IllegalStateException("arrow stream missing/empty: " + arrowPath); Try / catch
try {
reader.close();
} catch (RuntimeException e) {
LOG.warn("failed to close arrow stream reader", e.getCause());
} Prevention
- Close the reader exactly once, guarded by a boolean flag
- Always close via try-with-resources or finally so allocator leaks don't compound failures
- Check file/stream integrity (size, checksum) before reading Arrow streams
- Log the cause, not just the wrapper, when diagnosing close failures
When it happens
Trigger: Calling close() on an ArrowToSeatunnelRowReader whose underlying ArrowStreamReader.close() throws IOException, e.g. when the input stream is already corrupted/closed or the read side errored earlier. RootAllocator close must also have succeeded for the reader close branch to run.
Common situations: Arrow file/stream truncated on disk or in network transfer; reader closed after a prior read exception; filesystem (HDFS/S3) connection dropped mid-stream; closing reader twice in custom source code.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- Source fetch execution was fail
- Error while closing Databend source reader
- Closing streamLoadHttpClient failed.
- Closing httpClient failed.
- Failed to close Neo4j source reader.
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/0a5f3432335705a8.
Report an issue: GitHub.