{"record":{"id":"ded1ebc1d485c321","repo":"apache/seatunnel","slug":"flush-data-failed-ded1eb","errorCode":"FLUSH_DATA_FAILED","errorMessage":"Writing records to IoTDB failed.","messagePattern":"Writing records to IoTDB failed\\.","errorType":"error_code","errorClass":"IotdbConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-iotdb-v2/src/main/java/org/apache/seatunnel/connectors/seatunnel/iotdbv2/sink/relational/IoTDBv2RelationalSinkClient.java","lineNumber":226,"sourceCode":"    }\n\n    synchronized void flush() {\n        checkFlushException();\n        if (batchList.isEmpty()) {\n            return;\n        }\n\n        int maxRetries = sinkConfig.getMaxRetries();\n        for (int i = 0; i <= maxRetries; i++) {\n            try {\n                for (Tablet tablet : batchList) {\n                    tableSession.insert(tablet);\n                }\n                break;\n            } catch (IoTDBConnectionException | StatementExecutionException e) {\n                log.error(\"Writing records to IoTDB failed, retry times = {}\", i, e);\n                if (i >= sinkConfig.getMaxRetries()) {\n                    throw new IotdbConnectorException(\n                            CommonErrorCodeDeprecated.FLUSH_DATA_FAILED,\n                            \"Writing records to IoTDB failed.\",\n                            e);\n                }\n                try {\n                    long backoff =\n                            Math.min(\n                                    sinkConfig.getRetryBackoffMultiplierMs() * i,\n                                    sinkConfig.getMaxRetryBackoffMs());\n                    Thread.sleep(backoff);\n                } catch (InterruptedException ex) {\n                    Thread.currentThread().interrupt();\n                    throw new IotdbConnectorException(\n                            CommonErrorCodeDeprecated.FLUSH_DATA_FAILED,\n                            \"Unable to flush; interrupted while doing another attempt.\",\n                            e);\n                }\n            }","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-iotdb-v2/src/main/java/org/apache/seatunnel/connectors/seatunnel/iotdbv2/sink/relational/IoTDBv2RelationalSinkClient.java#L208-L244","documentation":"Thrown by flush() when inserting the Tablet into IoTDB fails on every retry attempt (IoTDBConnectionException or StatementExecutionException) up to sinkConfig.getMaxRetries(). All buffered records for the batch are effectively lost for this attempt; in streaming mode this typically fails the writer/task. The final exception carries the last underlying cause.","triggerScenarios":"tableSession.insert(tablet) repeatedly fails: database/table dropped or schema conflicts, statement exceeds size limits, type mismatch on column values, server overload, or connection lost and stays lost for all retries.","commonSituations":"IoTDB restarted or under heavy load during the job; table schema changed (column added/renamed) mid-run causing StatementExecutionException; batch too large hitting max_insert size; network partition between worker and IoTDB longer than the retry window.","solutions":["Read the wrapped cause: IoTDBConnectionException => connectivity; StatementExecutionException => SQL/schema issue, fix accordingly","Increase max_retries and retry backoff settings in sink config to tolerate transient outages","Verify the target table schema matches the records being written (column names/types)","Reduce batch size if inserts are rejected for size reasons","Ensure IoTDB capacity: check server logs for throttle/reject messages and disk space"],"exampleFix":"// before\nsink {\n  IoTDB-v2 {\n    max_retries = 3\n  }\n}\n// after\nsink {\n  IoTDB-v2 {\n    max_retries = 10\n    retry_backoff_multiplier_ms = 200\n    max_retry_backoff_ms = 60000\n  }\n}","handlingStrategy":"retry","validationCode":"// pre-check connectivity and target table existence\nboolean ok = ncProbe(iotdbHost, 6667) && sessionExistsTable(database, tableName);","typeGuard":null,"tryCatchPattern":"try {\n    client.flush();\n} catch (IotdbConnectorException e) {\n    if (e.getCause() instanceof StatementExecutionException) {\n        // fix schema/SQL problem; retries won't help\n    } else if (e.getCause() instanceof IoTDBConnectionException) {\n        // wait for recovery then retrigger / rely on checkpoint restart\n    }\n    throw e;\n}","preventionTips":["Tune max_retries and backoff above expected outage durations","Monitor IoTDB health and capacity (disk, load) alongside the job","Keep sink schema in sync with table DDL (schema registry/CI check)","Keep batch sizes within server insert limits"],"tags":["iotdb","write-failed","retry-exhausted","flush"],"backgroundTag":"database-write-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}