{"record":{"id":"66a52d11adb8bbde","repo":"apache/seatunnel","slug":"common-flush-data-failed","errorCode":"COMMON_FLUSH_DATA_FAILED","errorMessage":"Clickhouse execute batch statement error","messagePattern":"Clickhouse execute batch statement error","errorType":"error_code","errorClass":"ClickhouseConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/client/ClickhouseSinkWriter.java","lineNumber":134,"sourceCode":"        flush();\n    }\n\n    private void addIntoBatch(SeaTunnelRow row, JdbcBatchStatementExecutor clickHouseStatement) {\n        try {\n            clickHouseStatement.addToBatch(row);\n        } catch (SQLException e) {\n            throw new ClickhouseConnectorException(\n                    CommonErrorCodeDeprecated.SQL_OPERATION_FAILED,\n                    \"Add row data into batch error\",\n                    e);\n        }\n    }\n\n    private void flush(JdbcBatchStatementExecutor clickHouseStatement) {\n        try {\n            clickHouseStatement.executeBatch();\n        } catch (Exception e) {\n            throw new ClickhouseConnectorException(\n                    CommonErrorCodeDeprecated.FLUSH_DATA_FAILED,\n                    \"Clickhouse execute batch statement error\",\n                    e);\n        }\n    }\n\n    private void flush() {\n        for (ClickhouseBatchStatement batchStatement : statementMap.values()) {\n            try (ClickHouseConnectionImpl needClosedConnection =\n                            batchStatement.getClickHouseConnection();\n                    JdbcBatchStatementExecutor needClosedStatement =\n                            batchStatement.getJdbcBatchStatementExecutor()) {\n                IntHolder intHolder = batchStatement.getIntHolder();\n                if (intHolder.getValue() > 0) {\n                    flush(needClosedStatement);\n                    intHolder.setValue(0);\n                }\n            } catch (SQLException e) {","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/client/ClickhouseSinkWriter.java#L116-L152","documentation":"ClickhouseSinkWriter.flush wraps any exception from executing the accumulated JDBC batch against ClickHouse (network issues, SQL/schema mismatch, duplicate keys, server errors) into a ClickhouseConnectorException, failing the write.","triggerScenarios":"executeBatch fails during flush() called from write(), flushPendingStatements, or checkpoint flush: syntax errors in generated INSERT, server-side rejection (too many parts, memory limit, dedup conflicts), or connection loss.","commonSituations":"ClickHouse 'Too many parts' from frequent small flushes, 'Memory limit exceeded' on large batches, table is read-only, or network interruption to the ClickHouse server.","solutions":["Read the wrapped cause exception for the server-side error message","Increase batch_size / flush interval to reduce 'Too many parts' pressure","Increase ClickHouse max_insert_block_size/memory limits or reduce writer parallelism","Verify connectivity and table write permissions; enable retry for transient failures"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { writer.flush(); } catch (ClickhouseConnectorException e) {\n  if (e.getCode().equals(CommonErrorCodeDeprecated.FLUSH_DATA_FAILED)) {\n    Throwable cause = e.getCause(); // inspect server error, then retry with backoff\n  }\n}","preventionTips":["Tune batch_size/flush interval to avoid ClickHouse 'Too many parts'","Monitor ClickHouse memory limits and insert block sizes","Ensure stable connectivity and idempotent/retryable sink behavior"],"tags":["clickhouse","jdbc","flush","batch-write"],"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-14T05:17:10.506Z"}