apache/seatunnel · critical · IotdbConnectorException

FLUSH_DATA_FAILED

FLUSH_DATA_FAILED

Error message

Writing records to IoTDB failed.

What it means

IoTDBv2SinkClient.flush() inserts buffered records via session.insert... and retries on IoTDBConnectionException/StatementExecutionException up to sinkConfig.getMaxRetries(). If retries are exhausted, it wraps the last exception in IotdbConnectorException with CommonErrorCodeDeprecated.FLUSH_DATA_FAILED and message "Writing records to IoTDB failed." — the data could not be written after the configured retry budget.

Source

Thrown at seatunnel-connectors-v2/connector-iotdb-v2/src/main/java/org/apache/seatunnel/connectors/seatunnel/iotdbv2/sink/IoTDBv2SinkClient.java:144

                if (batchRecords.getTypesList().isEmpty()) {
                    session.insertRecords(
                            batchRecords.getDeviceIds(),
                            batchRecords.getTimestamps(),
                            batchRecords.getMeasurementsList(),
                            batchRecords.getStringValuesList());
                } else {
                    session.insertRecords(
                            batchRecords.getDeviceIds(),
                            batchRecords.getTimestamps(),
                            batchRecords.getMeasurementsList(),
                            batchRecords.getTypesList(),
                            batchRecords.getValuesList());
                }
                break;
            } catch (IoTDBConnectionException | StatementExecutionException e) {
                log.error("Writing records to IoTDB failed, retry times = {}", i, e);
                if (i >= sinkConfig.getMaxRetries()) {
                    throw new IotdbConnectorException(
                            CommonErrorCodeDeprecated.FLUSH_DATA_FAILED,
                            "Writing records to IoTDB failed.",
                            e);
                }

                try {
                    long backoff =
                            Math.min(
                                    sinkConfig.getRetryBackoffMultiplierMs() * i,
                                    sinkConfig.getMaxRetryBackoffMs());
                    Thread.sleep(backoff);
                } catch (InterruptedException ex) {
                    Thread.currentThread().interrupt();
                    throw new IotdbConnectorException(
                            CommonErrorCodeDeprecated.FLUSH_DATA_FAILED,
                            "Unable to flush; interrupted while doing another attempt.",
                            e);
                }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Read the wrapped cause (IoTDBConnectionException vs StatementExecutionException) — fix accordingly: reconnectivity issue vs invalid insert
  2. Increase max_retries / retry backoff options for transient network or load-related failures
  3. If the cause is StatementExecutionException, check the target database/timeseries exist (enable auto-create or pre-create) and value types match the measurement schema
  4. Check IoTDB server logs and health (disk space, wal, memory) around the failure time
  5. Verify network stability between workers and IoTDB (keepalives, LB idle timeouts killing sessions)

Example fix

// before
max_retries = 1
// after
max_retries = 5
retry_backoff_multiplier_ms = 100
max_retry_backoff_ms = 60000
Defensive patterns

Strategy: retry

Validate before calling

// ensure target database/timeseries exist before job start
Session session = new Session(host, port, user, password);
session.open(false);
session.setStorageGroup(dbName); // or enable auto-create in sink config

Try / catch

try {
    sink.write(row);
} catch (IotdbConnectorException e) {
    if (e.getSeaTunnelErrorCode() == CommonErrorCodeDeprecated.FLUSH_DATA_FAILED) {
        Throwable root = e.getCause();
        // IoTDBConnectionException -> network/retry tuning;
        // StatementExecutionException -> fix schema/timeseries
    }
    throw e;
}

Prevention

When it happens

Trigger: Repeated session insert failures during flush (called from write and close): connection drops mid-batch, IoTDB rejects the insert statement (schema/insert errors), server overload, or session expiry — every retry also fails until max_retries is exceeded.

Common situations: IoTDB restarted or network partition during a job; StatementExecutionException from a bad measurement type or uncreated database/timeseries when auto-create is off; batch too large / memory pressure on the server; wrong retry/backoff tuning for transient load spikes.

Related errors


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