{"record":{"id":"ed869a79029e1c01","repo":"apache/seatunnel","slug":"no-result-returned-after-running-query-minquery-ed869a","errorCode":null,"errorMessage":"No result returned after running query [${minQuery}]","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":129,"sourceCode":"            String columnName,\n            Column column,\n            Object excludedLowerBound)\n            throws SQLException {\n        columnName = quote(columnName);\n        if (column != null) {\n            columnName = JDBC_DIALECT.convertType(columnName, column.typeName());\n        }\n        final String minQuery =\n                String.format(\n                        \"SELECT MIN(%s) FROM %s WHERE %s > ?\",\n                        columnName, quote(tableId), columnName);\n        return jdbc.prepareQueryAndMap(\n                minQuery,\n                ps -> ps.setObject(1, excludedLowerBound),\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]\", minQuery));\n                    }\n                    return rs.getObject(1);\n                });\n    }\n\n    public static Object[] sampleDataFromColumn(\n            JdbcConnection jdbc, TableId tableId, String columnName, int inverseSamplingRate)\n            throws SQLException {\n        final String minQuery =\n                String.format(\n                        \"SELECT %s FROM %s WHERE MOD((%s - (SELECT MIN(%s) FROM %s)), %s) = 0 ORDER BY %s\",\n                        quote(columnName),\n                        quote(tableId),\n                        quote(columnName),\n                        quote(columnName),\n                        quote(tableId),","sourceCodeStart":111,"sourceCodeEnd":147,"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#L111-L147","documentation":"PostgresUtils.queryMin runs a parameterized 'SELECT MIN(col) FROM table WHERE col > ?' query to find the next chunk max during incremental snapshot splitting. If the ResultSet has no row it throws SQLException 'No result returned after running query [..]'; the code comments this should never occur because aggregates always yield one row.","triggerScenarios":"rs.next() is false for the MIN aggregate query — abnormal driver/connection behavior, cancelled statement, or result set closed before iteration. Not triggered merely by zero matching rows (MIN would return NULL, not an empty set).","commonSituations":"Statement cancellation due to timeout on a very large table; connection invalidated mid-query; JDBC proxy/firewall stripping results.","solutions":["Run the printed minQuery manually against the database to confirm behavior","Check for statement_timeout or cancellations in Postgres logs for this query","Verify network/connection stability and retry the failing split","Update the Postgres JDBC driver if using an old version with known result-set issues"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { min = PostgresUtils.queryMin(jdbc, tableId, col, lowerBound); } catch (SQLException e) { log.warn(\"retry chunk min: {}\", e.getMessage()); }","preventionTips":["Raise statement_timeout for chunk-boundary scans","Keep connections alive (TCP keepalive) during long snapshots","Check Postgres logs for cancellations"],"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"}