apache/seatunnel · error · CouchbaseConnectorException
WRITE_RECORDS_FAILED
WRITE_RECORDS_FAILED
Error message
Flush failed during close
What it means
close() performs a final flush of buffered records; if that flush throws and the exception is not already a CouchbaseConnectorException, it is wrapped as WRITE_RECORDS_FAILED with message 'Flush failed during close'. This ensures buffered data loss during shutdown is surfaced instead of silently swallowed.
Solutions
- Inspect the wrapped cause (getCause) for the underlying network/cluster error
- Ensure the Couchbase cluster is reachable and credentials valid before job ends
- Verify network/DNS/firewall stability during job teardown
- Increase timeout/retry settings if the final batch is large
Example fix
// before
// ignoring cause
catch (Exception e) { log.warn(e.getMessage()); }
// after
catch (CouchbaseConnectorException e) {
log.error("flush failed during close: {}", e.getCause(), e);
throw e;
} Defensive patterns
Strategy: try-catch
Try / catch
java
try {
writer.close();
} catch (CouchbaseConnectorException e) {
Throwable cause = e.getCause();
// log cause; decide retry or accept data-loss on shutdown
} Prevention
- Ensure cluster reachability before job teardown
- Avoid closing connections the writer still depends on
- Keep buffers small so final flush is fast
When it happens
Trigger: Buffered records exist and close() triggers doFlush which fails (network error, cluster unreachable, timeout, interruption); disconnect also throwing but a primary flush exception already captured.
Common situations: Job shutdown while Couchbase cluster is unreachable; connection pool closed before writer close; last flush exceeding timeouts.
Related errors
- Ambiguous timeout on Couchbase write
- clickhouse local file not exists
- CLOSE_CONNECTION_FAILED
- CLOSE_FAILED
- COMMIT_FAILED
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/427cc11f3a85c261.
Report an issue: GitHub.
Appendix: source
Thrown at seatunnel-connectors-v2/connector-couchbase/src/main/java/org/apache/seatunnel/connectors/seatunnel/couchbase/sink/CouchbaseWriter.java:223
} catch (Exception disconnectEx) {
if (primaryThrowable != null) {
// Issue 2: preserve the flush error as the primary cause; attach the
// disconnect failure so it is visible but does not mask the root cause.
primaryThrowable.addSuppressed(disconnectEx);
} else {
primaryThrowable =
new CouchbaseConnectorException(
CouchbaseConnectorErrorCode.CLOSE_CLIENT_FAILED,
"Failed to disconnect Couchbase cluster",
disconnectEx);
}
}
}
if (primaryThrowable != null) {
if (primaryThrowable instanceof CouchbaseConnectorException) {
throw (CouchbaseConnectorException) primaryThrowable;
}
throw new CouchbaseConnectorException(
CouchbaseConnectorErrorCode.WRITE_RECORDS_FAILED,
"Flush failed during close",
primaryThrowable);
}
}
// ---------------------------------------------------------------------------
// Internal helpers
// ---------------------------------------------------------------------------
/** Converts a {@link SeaTunnelRow} to a {@link JsonObject} using the schema field names. */
private JsonObject toJsonObject(SeaTunnelRow row) {
JsonObject doc = JsonObject.create();
String[] fieldNames = rowType.getFieldNames();
SeaTunnelDataType<?>[] fieldTypes = rowType.getFieldTypes();
for (int i = 0; i < fieldNames.length; i++) {
Object value = row.getField(i);
if (value == null) {
doc.putNull(fieldNames[i]);View on GitHub (pinned to cf67b549a7)