apache/seatunnel · warning · AerospikeConnectorException

WRITER_CLOSE_FAILED

WRITER_CLOSE_FAILED

Error message

Failed to close writer

What it means

AerospikeSinkWriter.close closes the AerospikeClient; any exception during aerospikeClient.close() is wrapped into AerospikeConnectorException WRITER_CLOSE_FAILED with message 'Failed to close writer'. This occurs during sink teardown and usually reflects an already-failing client/cluster rather than data loss.

Source

Thrown at seatunnel-connectors-v2/connector-aerospike/src/main/java/org/apache/seatunnel/connectors/seatunnel/aerospike/sink/AerospikeSinkWriter.java:156

                default:
                    throw new IllegalArgumentException(
                            "Unsupported data format type: " + formatType);
            }
        } catch (Exception e) {
            throw new AerospikeConnectorException(
                    AerospikeErrorCode.WRITER_OPERATION_FAILED, "Failed to write record", e);
        }
    }

    @Override
    public void close() throws IOException {
        try {
            if (Objects.nonNull(aerospikeClient)) {
                aerospikeClient.close();
            }
        } catch (Exception e) {
            throw new AerospikeConnectorException(
                    AerospikeErrorCode.WRITER_CLOSE_FAILED, "Failed to close writer", e);
        }
    }

    private AerospikeClient buildClient() {
        ClientPolicy clientPolicy = new ClientPolicy();
        clientPolicy.user = config.get(AerospikeSinkOptions.USERNAME);
        clientPolicy.password = config.get(AerospikeSinkOptions.PASSWORD);
        clientPolicy.timeout = config.get(AerospikeSinkOptions.WRITE_TIMEOUT);
        clientPolicy.maxConnsPerNode = 300;

        return new AerospikeClient(
                clientPolicy,
                config.get(AerospikeSinkOptions.HOST),
                config.get(AerospikeSinkOptions.PORT));
    }

    private Object convertValue(Object value, AerospikeDataType dataType) {

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Verify cluster health at job shutdown; fix the underlying connectivity issue
  2. Check earlier logs for the primary failure that preceded close
  3. Treat as secondary error during cleanup; ensure data integrity from earlier write results
  4. Ensure close() is only called once per writer lifecycle
Defensive patterns

Strategy: try-catch

Try / catch

try { writer.close(); } catch (AerospikeConnectorException e) { if (e.getErrorCode() == WRITER_CLOSE_FAILED) { log.warn("aerospike writer close failed; likely cluster/client already unhealthy", e); } }

Prevention

When it happens

Trigger: Calling close() when aerospikeClient.close() throws — e.g. cluster node drained, client already closed/aborted, or underlying IO errors during shutdown.

Common situations: Aerospike cluster shut down before the job finishes; previous write failures left the client in a bad state; repeated close invocations.

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


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/7c502de93a18dfd3. Report an issue: GitHub.