{"record":{"id":"e9aa2bbc2dbf212c","repo":"apache/seatunnel","slug":"commonerrorcodedeprecated-flush-data-failed","errorCode":"CommonErrorCodeDeprecated.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/src/main/java/org/apache/seatunnel/connectors/seatunnel/iotdb/sink/IoTDBSinkClient.java","lineNumber":144,"sourceCode":"            try {\n                if (batchRecords.getTypesList().isEmpty()) {\n                    session.insertRecords(\n                            batchRecords.getDeviceIds(),\n                            batchRecords.getTimestamps(),\n                            batchRecords.getMeasurementsList(),\n                            batchRecords.getStringValuesList());\n                } else {\n                    session.insertRecords(\n                            batchRecords.getDeviceIds(),\n                            batchRecords.getTimestamps(),\n                            batchRecords.getMeasurementsList(),\n                            batchRecords.getTypesList(),\n                            batchRecords.getValuesList());\n                }\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\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                }","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-iotdb/src/main/java/org/apache/seatunnel/connectors/seatunnel/iotdb/sink/IoTDBSinkClient.java#L126-L162","documentation":"The IoTDB sink writer failed to insert batched records into Apache IoTDB. IoTDBSinkClient.flush() retries insertTablet/insertAlignedTablet calls on IoTDBConnectionException or StatementExecutionException; after exhausting sinkConfig.maxRetries it wraps the last exception in IotdbConnectorException with FLUSH_DATA_FAILED. This aborts the write so the engine can fail/restart the task rather than silently lose records.","triggerScenarios":"session.executeBatchStatement/insert call throws IoTDBConnectionException or StatementExecutionException on every attempt and the loop index reaches sinkConfig.getMaxRetries(); called from write() (buffer full) or close().","commonSituations":"IoTDB host/port wrong or node down; session expired or dropped by server idle timeout; wrong username/password; SQL/tablet schema mismatch (bad measurement types or unsupported SQL); IoTDB under heavy load causing timeouts.","solutions":["Verify IoTDB connectivity (host, port, user, password, rpc_port) with a quick session test from the SeaTunnel node.","Increase sink maxRetries / retry backoff options so transient outages are survived.","Check IoTDB server logs for the underlying StatementExecutionException cause and fix the offending SQL/tablet schema.","Ensure the IoTDB cluster is up and network/firewall allows the connection; restart stale sessions.","Upgrade/check connector and IoTDB client versions for compatibility."],"exampleFix":"// before\nsink {\n  IoTDB {\n    node_urls = \"localhost:6667\"\n  }\n}\n// after\nsink {\n  IoTDB {\n    node_urls = \"iotdb-host:6667\"\n    username = \"root\"\n    password = \"root\"\n    max_retries = 10\n    retry_backoff_multiplier_ms = 500\n    max_retry_backoff_ms = 10000\n  }\n}","handlingStrategy":"retry","validationCode":"try (var session = new Session.Builder().host(nodes[0].split(\":\")[0]).port(Integer.parseInt(nodes[0].split(\":\")[1])).username(user).password(pass).build()) { session.open(false); session.close(); }","typeGuard":null,"tryCatchPattern":"catch (IotdbConnectorException e) { if (e.getErrorCode() == CommonErrorCodeDeprecated.FLUSH_DATA_FAILED) { /* alert, checkpoint-restart, or fail job */ } }","preventionTips":["Validate IoTDB host/port/credentials with a test session before job launch","Set generous maxRetries and backoff options for transient outages","Monitor IoTDB server health and load","Keep connector and IoTDB client versions compatible"],"tags":["iotdb","sink","write-failure","retry-exhausted"],"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"}