{"record":{"id":"738159996ea34738","repo":"apache/seatunnel","slug":"flush-data-failed-738159","errorCode":"FLUSH_DATA_FAILED","errorMessage":"Writing records to IoTDB failed.","messagePattern":"Writing records to IoTDB failed\\.","errorType":"error_code","errorClass":"IotdbConnectorException","httpStatus":null,"severity":"critical","filePath":"seatunnel-connectors-v2/connector-iotdb-v2/src/main/java/org/apache/seatunnel/connectors/seatunnel/iotdbv2/sink/IoTDBv2SinkClient.java","lineNumber":144,"sourceCode":"                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                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\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-v2/src/main/java/org/apache/seatunnel/connectors/seatunnel/iotdbv2/sink/IoTDBv2SinkClient.java#L126-L162","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the wrapped cause (IoTDBConnectionException vs StatementExecutionException) — fix accordingly: reconnectivity issue vs invalid insert","Increase max_retries / retry backoff options for transient network or load-related failures","If the cause is StatementExecutionException, check the target database/timeseries exist (enable auto-create or pre-create) and value types match the measurement schema","Check IoTDB server logs and health (disk space, wal, memory) around the failure time","Verify network stability between workers and IoTDB (keepalives, LB idle timeouts killing sessions)"],"exampleFix":"// before\nmax_retries = 1\n// after\nmax_retries = 5\nretry_backoff_multiplier_ms = 100\nmax_retry_backoff_ms = 60000","handlingStrategy":"retry","validationCode":"// ensure target database/timeseries exist before job start\nSession session = new Session(host, port, user, password);\nsession.open(false);\nsession.setStorageGroup(dbName); // or enable auto-create in sink config","typeGuard":null,"tryCatchPattern":"try {\n    sink.write(row);\n} catch (IotdbConnectorException e) {\n    if (e.getSeaTunnelErrorCode() == CommonErrorCodeDeprecated.FLUSH_DATA_FAILED) {\n        Throwable root = e.getCause();\n        // IoTDBConnectionException -> network/retry tuning;\n        // StatementExecutionException -> fix schema/timeseries\n    }\n    throw e;\n}","preventionTips":["Set max_retries and retry backoff high enough to ride out transient blips","Pre-create the database/timeseries or enable measurement auto-creation","Keep batch sizes moderate to avoid oversized inserts","Monitor IoTDB server health (disk, memory, wal) and network stability"],"tags":["iotdb","write-failure","retry","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"}