{"record":{"id":"2c4aceda246595fc","repo":"apache/seatunnel","slug":"no-result-returned-after-running-query-query-2c4ace","errorCode":null,"errorMessage":"No result returned after running query [${query}]","messagePattern":"No result returned after running query \\[(.+?)\\]","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/postgres/utils/PostgresUtils.java","lineNumber":254,"sourceCode":"        }\n        String query =\n                String.format(\n                        \"SELECT MAX(%s) FROM (\"\n                                + \"SELECT %s FROM %s WHERE %s >= ? ORDER BY %s ASC \"\n                                + \"LIMIT %s) AS T\",\n                        quotedColumn,\n                        quotedColumn,\n                        quote(tableId),\n                        quotedColumn,\n                        quotedColumn,\n                        chunkSize);\n        return jdbc.prepareQueryAndMap(\n                query,\n                ps -> ps.setObject(1, includedLowerBound),\n                rs -> {\n                    if (!rs.next()) {\n                        // this should never happen\n                        throw new SQLException(\n                                String.format(\n                                        \"No result returned after running query [%s]\", query));\n                    }\n                    return rs.getObject(1);\n                });\n    }\n\n    public static SeaTunnelRowType getSplitType(Table table) {\n        List<Column> primaryKeys = table.primaryKeyColumns();\n        if (primaryKeys.isEmpty()) {\n            throw new SeaTunnelException(\n                    String.format(\n                            \"Incremental snapshot for tables requires primary key,\"\n                                    + \" but table %s doesn't have primary key.\",\n                            table.id()));\n        }\n\n        // use first field in primary key as the split key","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/postgres/utils/PostgresUtils.java#L236-L272","documentation":"PostgresUtils.queryNextChunkMax builds and runs a query selecting the maximum chunk-key value above a lower bound to advance incremental snapshot chunk boundaries. If the returned ResultSet contains no row it throws SQLException 'No result returned after running query [..]'.","triggerScenarios":"The chunk-max aggregate query returns an empty result set — abnormal driver behavior, statement cancellation, or the underlying table vanishing between chunk steps. An empty table/range normally yields a single NULL row, not an empty set.","commonSituations":"Long-running snapshot where the table is dropped concurrently; Postgres failover interrupting the cursor; timeouts on heavy MAX scans.","solutions":["Confirm the table still exists and the connection is healthy; re-run the job (chunks restart)","Check Postgres logs for cancelled statements or failover during the snapshot window","Execute the query from the message manually to reproduce/validate","Raise timeouts for large chunk scans or reduce chunk size"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { nextMax = PostgresUtils.queryNextChunkMax(jdbc, tableId, col, chunkSize, lowerBound); } catch (SQLException e) { log.warn(\"chunk boundary read failed, restarting split\", e); }","preventionTips":["Avoid concurrent DROP/TRUNCATE during snapshot","Reduce chunk size to shorten each MAX scan","Monitor for failovers and restart the job cleanly"],"tags":["postgres","jdbc","query","chunk-split"],"backgroundTag":"empty-result-set","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"}