apache/seatunnel · error · IOException
Failed to close HugeGraph sink writer
Error message
Failed to close HugeGraph sink writer
What it means
On close(), HugeGraphSinkWriter replays the first failure captured during earlier close steps (IO or runtime exceptions are rethrown as-is); any other non-null failure cause is wrapped in an IOException with this message. This ensures resource-cleanup failures are never silently swallowed during job shutdown.
Source
Thrown at seatunnel-connectors-v2/connector-hugegraph/src/main/java/org/apache/seatunnel/connectors/seatunnel/hugegraph/sink/HugeGraphSinkWriter.java:863
if (client != null) {
client.close();
}
} catch (Exception closeFailure) {
if (failure == null) {
failure = closeFailure;
} else {
failure.addSuppressed(closeFailure);
}
}
}
if (failure instanceof IOException) {
throw (IOException) failure;
}
if (failure instanceof RuntimeException) {
throw (RuntimeException) failure;
}
if (failure != null) {
throw new IOException("Failed to close HugeGraph sink writer", failure);
}
}
/** Package-private test accessor. */
List<MappingEntry> mappingEntries() {
return mappingEntries;
}
static class MappingEntry {
final MappingConfig config;
final GraphDataMapper mapper;
MappingEntry(MappingConfig config, GraphDataMapper mapper) {
this.config = config;
this.mapper = mapper;
}
}
}View on GitHub (pinned to cf67b549a7)
Solutions
- Inspect the 'Caused by' of the IOException to identify the original cleanup failure.
- Ensure the HugeGraph client is reachable/releasable at shutdown; check server logs for session close errors.
- Avoid interrupting the task thread while close() is executing.
- If a new checked exception type is thrown by cleanup code, handle or wrap it appropriately rather than letting it surface here.
Defensive patterns
Strategy: try-catch
Validate before calling
// ensure server reachable before closing // curl -s http://HOST:PORT/apis/version >/dev/null
Try / catch
try {
writer.close();
} catch (IOException e) {
LOG.error("HugeGraph writer close failed", e.getCause());
} Prevention
- Always call close() in a finally block or use try-with-resources.
- Do not interrupt worker threads during shutdown.
- Check the 'Caused by' chain for the root cleanup failure.
- Keep HugeGraph client sessions short-lived and closed deterministically.
When it happens
Trigger: close() is called (by the engine or tests like testVertexInsert) and an exception was captured during resource cleanup that is neither IOException nor RuntimeException, so it is wrapped and rethrown as IOException("Failed to close HugeGraph sink writer", failure).
Common situations: HugeGraph client/session cannot be released cleanly because the server is unreachable; thread interruption during close; an unexpected checked exception (neither IO nor Runtime) thrown by a cleanup routine.
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
- WRITER_CLOSE_FAILED
- CLOSE_CLIENT_FAILED
- Failed to close Neo4j sink writer.
- Failed to close Pulsar client after aborting transactions.
- Failed to close Pulsar sink writer.
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/0a764f65cc3a97d8.
Report an issue: GitHub.