{"record":{"id":"c92f4686aa9b2e7d","repo":"apache/seatunnel","slug":"no-result-returned-after-running-query-s-c92f46","errorCode":null,"errorMessage":"No result returned after running query [%s]","messagePattern":"No result returned after running query \\[(.+?)\\]","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/utils/MySqlUtils.java","lineNumber":66,"sourceCode":"\n/** Utils to prepare MySQL SQL statement. */\n@Slf4j\npublic class MySqlUtils {\n\n    private MySqlUtils() {}\n\n    public static Object[] queryMinMax(JdbcConnection jdbc, TableId tableId, String columnName)\n            throws SQLException {\n        final String minMaxQuery =\n                String.format(\n                        \"SELECT MIN(%s), MAX(%s) FROM %s\",\n                        quote(columnName), quote(columnName), quote(tableId));\n        return jdbc.queryAndMap(\n                minMaxQuery,\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]\",\n                                        minMaxQuery));\n                    }\n                    return rowToArray(rs, 2);\n                });\n    }\n\n    public static long queryApproximateRowCnt(JdbcConnection jdbc, TableId tableId)\n            throws SQLException {\n        // The statement used to get approximate row count which is less\n        // accurate than COUNT(*), but is more efficient for large table.\n        final String useDatabaseStatement = String.format(\"USE %s;\", quote(tableId.catalog()));\n        final String rowCountQuery = String.format(\"SHOW TABLE STATUS LIKE '%s';\", tableId.table());\n        // Otherwise will case this error: Cannot execute without committing because auto-commit is\n        // enabled\n        jdbc.execute(useDatabaseStatement);\n        return jdbc.queryAndMap(","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/utils/MySqlUtils.java#L48-L84","documentation":"MySqlUtils.queryMinMax executes `SELECT MIN(col), MAX(col) FROM table` and throws this SQLException if the ResultSet has no rows. Normally MIN/MAX over a table always returns one row, so the comment says 'this should never happen'; it is an internal-invariant guard distinguishing an empty/invalid result from a real query error.","triggerScenarios":"Calling queryMinMax on a table whose split column yields no row from the aggregate query — practically only when the table disappeared mid-chunk-planning, the query returned zero rows due to a server anomaly, or the JDBC driver misbehaved.","commonSituations":"Table dropped/truncated between split enumeration and MIN/MAX planning; MySQL proxy returning empty result sets; corrupt metadata after a failed DDL.","solutions":["Re-run the job; transient anomalies usually resolve on retry","Verify the table still exists and is non-degenerate when planning starts (SELECT COUNT(*) works)","Check for intermediate proxies/load balancers that can swallow result sets","If reproducible, capture the minMaxQuery SQL from the message and run it manually in MySQL to diagnose"],"exampleFix":"// before\nObject[] minMax = MySqlUtils.queryMinMax(jdbc, tableId, columnName);\n// after\nif (MySqlUtils.isTableMissing(jdbc, tableId)) { skipTable(tableId); }\nObject[] minMax = MySqlUtils.queryMinMax(jdbc, tableId, columnName);","handlingStrategy":"retry","validationCode":"// ensure table exists and is queryable before split planning\ntry (ResultSet rs = st.executeQuery(\"SELECT MIN(c), MAX(c) FROM `t`\")) {\n    if (!rs.next()) throw new IllegalStateException(\"empty min/max result\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    Object[] minMax = MySqlUtils.queryMinMax(jdbc, tableId, col);\n} catch (SQLException e) {\n    // retry with backoff; abort table if DROP TABLE detected\n}","preventionTips":["Don't drop/alter tables during snapshot planning","Retry transient JDBC failures with backoff","Avoid proxies that can drop result sets","Run the failing query manually when it recurs"],"tags":["mysql","cdc","jdbc","empty-result"],"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"}