{"record":{"id":"f86b3481576f2650","repo":"apache/seatunnel","slug":"failed-to-read-data-from-part-s-shard-s-split","errorCode":null,"errorMessage":"Failed to read data from part %s, shard: %s, splitId: %s, message: %s","messagePattern":"Failed to read data from part (.+?), shard: (.+?), splitId: (.+?), message: (.+?)","errorType":"exception","errorClass":"ClickhouseConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/source/ClickhouseValueReader.java","lineNumber":161,"sourceCode":"\n            if (rowBatch.isEmpty()) {\n                currentPart.setEndOfPart(true);\n                currentPartIndex++;\n                return currentPartIndex < partSize && partBatchStrategyRead();\n            }\n\n            // update Keyset cursor (last ordering key values)\n            String sortingKey = clickhouseSourceTable.getClickhouseTable().getSortingKey();\n\n            SeaTunnelRow lastRow = rowBatch.get(rowBatch.size() - 1);\n            List<Object> keyValues = extractOrderingKeyValuesFromRow(lastRow, sortingKey);\n            log.debug(\"lastRow: {}, extract ordering key values from row: {}\", lastRow, keyValues);\n\n            currentPart.setLastOrderingKeyValues(keyValues);\n\n            return true;\n        } catch (Exception e) {\n            throw new ClickhouseConnectorException(\n                    ClickhouseConnectorErrorCode.QUERY_DATA_ERROR,\n                    String.format(\n                            \"Failed to read data from part %s, shard: %s, splitId: %s, message: %s\",\n                            currentPart.getName(),\n                            currentPart.getShard().getNode(),\n                            clickhouseSourceSplit.getSplitId(),\n                            e.getMessage()),\n                    e);\n        }\n    }\n\n    private boolean sqlBatchStrategyRead() {\n        String query = buildBatchSqlQuery();\n\n        try {\n            rowBatch =\n                    proxy.batchFetchRecords(\n                            query, clickhouseSourceTable.getTablePath(), rowTypeInfo);","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/source/ClickhouseValueReader.java#L143-L179","documentation":"Thrown by ClickhouseValueReader.partBatchStrategyRead() when any exception occurs while reading rows from a specific ClickHouse part. The connector wraps the underlying failure (JDBC/driver/network/parsing) in a ClickhouseConnectorException with QUERY_DATA_ERROR, attaching the part name, shard node, split id, and original message. It means data could not be read from that part during the part-based batch read strategy.","triggerScenarios":"partBatchStrategyRead() executes the per-part SELECT query against the shard node and any Exception is raised: connection failure to the shard, SQL syntax/schema mismatch, driver errors, or failure while extracting ordering key values from the last row.","commonSituations":"Shard node temporarily unreachable or restarted mid-read; ClickHouse user lacks SELECT permission on the part's table; schema changed so ordering key extraction fails; network timeouts on large parts.","solutions":["Verify the shard node in the error message is reachable and healthy (clickhouse-client against that node)","Check the ClickHouse user has SELECT grants on the target table and the part's database","Re-run the job — transient network/shard failures often resolve on retry; enable checkpointing so the split is re-read","Inspect the wrapped 'message' field for the root cause (driver/SQL error) and fix that underlying issue"],"exampleFix":"// before\nString sql = \"SELECT * FROM \" + tablePath;\n// after\nString sql = \"SELECT * FROM \" + tablePath + \" SETTINGS max_execution_time = 300\";\n// plus verify connectivity: clickhouse-client --host <shardNode> -q 'SELECT 1'","handlingStrategy":"retry","validationCode":"// Pre-check shard connectivity and grants before running the job\ntry (Connection c = DriverManager.getConnection(jdbcUrlOnShard, user, pass)) {\n    ResultSet rs = c.createStatement().executeQuery(\"SELECT 1\");\n    if (!rs.next()) throw new IllegalStateException(\"Shard not answering\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    rows = reader.next();\n} catch (ClickhouseConnectorException e) {\n    if (e.getErrorCode() == ClickhouseConnectorErrorCode.QUERY_DATA_ERROR\n        && e.getMessage().startsWith(\"Failed to read data from part\")) {\n        // inspect wrapped cause; retry with backoff or skip to next split via checkpoint recovery\n    }\n    throw e;\n}","preventionTips":["Monitor shard health and run the job only when all shards respond","Grant the ClickHouse user SELECT on all source tables before submitting the job","Enable checkpointing so interrupted part reads resume from the last committed position","Set sensible JDBC/socket timeouts matching part sizes"],"tags":["clickhouse","query","network","source-reader"],"backgroundTag":"database-query-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"}