{"record":{"id":"466ccc1bd486db4d","repo":"apache/seatunnel","slug":"no-result-returned-after-running-query-query","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-db2/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/db2/utils/Db2Utils.java","lineNumber":231,"sourceCode":"        String query =\n                String.format(\n                        \"SELECT MAX(%s) FROM (\"\n                                + \"SELECT %s FROM %s WHERE %s >= ? ORDER BY %s ASC \"\n                                + \"FETCH FIRST %s ROWS ONLY\"\n                                + \") 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":213,"sourceCodeEnd":249,"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#L213-L249","documentation":"Db2Utils.queryNextChunkMax reads the maximum split-column value of the next chunk (rows >= includedLowerBound LIMIT chunkSize). It throws this SQLException if the ResultSet is empty — an internal invariant, since the caller should only query chunks that contain at least one remaining row.","triggerScenarios":"queryNextChunkMax called with an includedLowerBound that matches no rows — typically rows deleted concurrently after the previous chunk was read, or the table being truncated mid-snapshot.","commonSituations":"Concurrent DELETE/truncate on the table during incremental snapshot; split planning raced with data mutation; incorrect retry after partial chunk read.","solutions":["Restart the snapshot job so chunk state is rebuilt from current data","Avoid bulk deletes/truncates while a snapshot is in progress","Report a bug if reproducible without concurrent writes","Enable lower retry/backoff for transient conflicts"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { Object max = Db2Utils.queryNextChunkMax(jdbc, query, includedLowerBound); } catch (SQLException e) { if (e.getMessage().contains(\"No result returned\")) { /* rebuild split state / restart snapshot */ } throw e; }","preventionTips":["Schedule truncations/bulk deletes outside snapshot windows","Re-run snapshot job to rebuild chunk state after data mutation","Report a reproducible case as a bug if no concurrent writes"],"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"}