{"record":{"id":"b9fb7d9ab93a1bf8","repo":"apache/seatunnel","slug":"write-row-failed","errorCode":"WRITE_ROW_FAILED","errorMessage":"Failed to send these rows of data: '%s'.","messagePattern":"Failed to send these rows of data: '(.+?)'\\.","errorType":"error_code","errorClass":"TablestoreConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-tablestore/src/main/java/org/apache/seatunnel/connectors/seatunnel/tablestore/sink/TableStoreSinkClient.java","lineNumber":90,"sourceCode":"\n    public void close() throws IOException {\n        if (syncClient != null) {\n            flush();\n            syncClient.shutdown();\n        }\n    }\n\n    synchronized void flush() {\n        checkFlushException();\n        if (batchList.isEmpty()) {\n            return;\n        }\n        BatchWriteRowRequest batchWriteRowRequest = new BatchWriteRowRequest();\n        batchList.forEach(batchWriteRowRequest::addRowChange);\n        BatchWriteRowResponse response = syncClient.batchWriteRow(batchWriteRowRequest);\n\n        if (!response.isAllSucceed()) {\n            throw new TablestoreConnectorException(\n                    TablestoreConnectorErrorCode.WRITE_ROW_FAILED,\n                    String.format(\n                            \"Failed to send these rows of data: '%s'.\", response.getFailedRows()));\n        }\n\n        batchList.clear();\n    }\n\n    private void checkFlushException() {\n        if (flushException != null) {\n            throw new TablestoreConnectorException(\n                    CommonErrorCodeDeprecated.FLUSH_DATA_FAILED,\n                    \"Writing items to Tablestore failed.\",\n                    flushException);\n        }\n    }\n}\n","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-tablestore/src/main/java/org/apache/seatunnel/connectors/seatunnel/tablestore/sink/TableStoreSinkClient.java#L72-L108","documentation":"Thrown by TableStoreSinkClient.flush() when the Alibaba Tablestore BatchWriteRowResponse reports that at least one row in the batch failed to write. The message includes the failed rows returned by the server so the developer can identify which rows were rejected and why.","triggerScenarios":"syncClient.batchWriteRow(batchWriteRowRequest) returns a response where isAllSucceed() is false, e.g. row changes rejected by Tablestore due to condition check failures, invalid primary key values, throttling, or oversized rows.","commonSituations":"Writing rows whose primary key exceeds size limits or contains nulls; batch sizes exceeding Tablestore limits; table capacity/throttling (OTSLimitExceeded); schema drift where column types no longer match the Tablestore table; attempting conditional updates that fail RowCondition checks.","solutions":["Inspect response.getFailedRows() in the message for ErrorCode/ErrorMessage per row and fix the offending row data (primary keys, column types, sizes).","Reduce batchList batch size to stay under Tablestore BatchWriteRow limits and avoid throttling.","Check the target table exists with the expected primary-key schema and capacity units; enable auto-scaling or raise CU quota.","Retry failed rows with backoff if the failure is transient throttling; otherwise fail the job with corrected data."],"exampleFix":"// before\nbatchList.add(changeFor(row)); // pk value may exceed limits\n// after\nif (pkValue == null || pkValue.getBytes(StandardCharsets.UTF_8).length > 1024) {\n    throw new IllegalArgumentException(\"Primary key too large/null: \" + row);\n}\nbatchList.add(changeFor(row));","handlingStrategy":"try-catch","validationCode":"// Validate rows before batching\nfor (SeaTunnelRow row : rows) {\n    if (row == null || row.getField(0) == null) throw new IllegalArgumentException(\"Null primary key: \" + row);\n}","typeGuard":"boolean isValidRow(SeaTunnelRow r) { return r != null && r.getField(0) != null && r.getArity() == expectedSchema.size(); }","tryCatchPattern":"try {\n    sinkWriter.write(row);\n} catch (TablestoreConnectorException e) {\n    log.error(\"Batch write failed; failed rows: {}\", e.getMessage(), e);\n    // requeue or dead-letter the rows in e.getMessage()\n}","preventionTips":["Match primary key schema and sizes to the Tablestore table definition before writing","Keep batch sizes within Tablestore BatchWriteRow limits","Monitor CU usage/throttling metrics on the target table","Log response.getFailedRows() details to diagnose per-row errors"],"tags":["tablestore","alibaba","batch-write","data-quality"],"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-23T08:17:48.524Z"}