{"record":{"id":"f41ea8e366de8467","repo":"apache/seatunnel","slug":"no-result-returned-after-running-query-minquery","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-db2/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/db2/utils/Db2Utils.java","lineNumber":116,"sourceCode":"                    }\n                    return rs.getLong(1);\n                });\n    }\n\n    public static Object queryMin(\n            JdbcConnection jdbc, TableId tableId, String columnName, Object excludedLowerBound)\n            throws SQLException {\n        final String minQuery =\n                String.format(\n                        \"SELECT MIN(%s) FROM %s WHERE %s > ?\",\n                        quote(columnName), quote(tableId), quote(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":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-db2/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/db2/utils/Db2Utils.java#L98-L134","documentation":"Db2Utils.queryMin fetches the minimum value of the split column for a chunk, excluding an optional lower bound. It throws this SQLException when the query returns no rows, which the code comments say 'should never happen' — it is an internal invariant that every chunk query yields at least one row.","triggerScenarios":"Calling queryMin for a chunk whose lower bound range no longer matches any rows — e.g. rows deleted concurrently between split planning and execution, or an empty table being chunked.","commonSituations":"Underlying table data deleted while incremental snapshot is running; snapshot planned against a table later truncated; race between chunk splitting and reading.","solutions":["Re-run the snapshot/job — transient concurrent deletes usually resolve it","Check whether rows in the chunk range are being aggressively purged during snapshotting","Exclude highly volatile tables from incremental snapshot or pause purging jobs","Report as a bug if reproducible on a static table"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { Object min = Db2Utils.queryMin(jdbc, minQuery, excludedLowerBound); } catch (SQLException e) { if (e.getMessage().startsWith(\"No result returned\")) { /* skip chunk or restart snapshot */ } throw e; }","preventionTips":["Avoid bulk DELETE/purge jobs during incremental snapshot","Exclude highly volatile tables from snapshotting","Retry the job on transient failures"],"tags":["db2","cdc","chunk-splitting","empty-result-set"],"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"}