apache/seatunnel · warning · CassandraConnectorException
CLOSE_CQL_SESSION_FAILED
CLOSE_CQL_SESSION_FAILED
Error message
CLOSE_CQL_SESSION_FAILED
What it means
CassandraSinkWriter.close() flushes then closes the CqlSession; if session.close() throws, the error is wrapped as CLOSE_CQL_SESSION_FAILED. The writer already flushed successfully, so pending data is safe — but the session cleanup failed, typically due to broken connections during shutdown.
Source
Thrown at seatunnel-connectors-v2/connector-cassandra/src/main/java/org/apache/seatunnel/connectors/seatunnel/cassandra/sink/CassandraSinkWriter.java:154
private String initPrepareCQL() {
String[] placeholder = new String[cassandraParameters.getFields().size()];
Arrays.fill(placeholder, "?");
return String.format(
"INSERT INTO %s (%s) VALUES (%s)",
cassandraParameters.getTable(),
String.join(",", cassandraParameters.getFields()),
String.join(",", placeholder));
}
@Override
public void close() throws IOException {
flush();
try {
if (this.session != null) {
this.session.close();
}
} catch (Exception e) {
throw new CassandraConnectorException(
CassandraConnectorErrorCode.CLOSE_CQL_SESSION_FAILED, e);
}
}
}
View on GitHub (pinned to cf67b549a7)
Solutions
- Usually safe to ignore for data correctness (flush already succeeded); verify checkpoint completed and data landed in the table.
- Check Cassandra node logs for disconnect reasons; fix network instability or node restarts during job lifetime.
- Ensure async writes are fully completed before close — increase flush/await windows if in-flight requests overlap shutdown.
- Upgrade the Cassandra Java driver if close consistently throws after healthy writes (known channel-close race issues).
Example fix
// before
try {
if (this.session != null) {
this.session.close();
}
} catch (Exception e) {
throw new CassandraConnectorException(CLOSE_CQL_SESSION_FAILED, e);
}
// after (application-side guard)
try (SinkWriter writer = ...) {
...
} catch (CassandraConnectorException e) {
if (e.getCode() == CLOSE_CQL_SESSION_FAILED) {
log.warn("Session close failed after flush; data already flushed", e);
} else {
throw e;
}
} Defensive patterns
Strategy: try-catch
Try / catch
// safe to downgrade: flush already completed before close
try {
writer.close();
} catch (CassandraConnectorException e) {
if (CassandraConnectorErrorCode.CLOSE_CQL_SESSION_FAILED.equals(e.getErrorCode())) {
log.warn("ignoring session close failure after successful flush");
} else { throw e; }
} Prevention
- Ensure async writes complete before close (await completionStages).
- Monitor Cassandra node health so sessions stay alive through job shutdown.
- Treat this error as non-fatal when checkpoint/flush succeeded.
When it happens
Trigger: this.session.close() throws — happens when the driver's channels are already dead (cluster restarted/network partitioned), or when close is racing with in-flight async writes that hold onto the session.
Common situations: Cassandra cluster unavailability at job shutdown; very short-lived tasks where the node disconnected before close; driver force-closing channels with in-flight requests.
Understand the failure class
Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.
Related errors
- COMMON_ERROR_CODE_DEPRECATED_TABLE_SCHEMA_GET_FAILED
- TABLE_SCHEMA_GET_FAILED
- RABBITMQ-03
- Failed to close catalog
- Failed to close Fluss connection for {}
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/2fd40081eb06ae69.
Report an issue: GitHub.