{"record":{"id":"10db1d6a026f0e25","repo":"apache/seatunnel","slug":"thread-interrupted-10db1d","errorCode":null,"errorMessage":"Thread interrupted","messagePattern":"Thread interrupted","errorType":"exception","errorClass":"InterruptedException","httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/utils/MySqlUtils.java","lineNumber":171,"sourceCode":"            stmt =\n                    jdbc.connection()\n                            .createStatement(\n                                    ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);\n\n            stmt.setFetchSize(Integer.MIN_VALUE);\n            rs = stmt.executeQuery(sampleQuery);\n\n            int count = 0;\n            while (rs.next()) {\n                count++;\n                if (count % 100000 == 0) {\n                    log.info(\"Processing row index: {}\", count);\n                }\n                if (count % inverseSamplingRate == 0) {\n                    results.add(rs.getObject(1));\n                }\n                if (Thread.currentThread().isInterrupted()) {\n                    throw new InterruptedException(\"Thread interrupted\");\n                }\n            }\n        } finally {\n            if (rs != null) {\n                try {\n                    rs.close();\n                } catch (SQLException e) {\n                    log.error(\"Failed to close ResultSet\", e);\n                }\n            }\n            if (stmt != null) {\n                try {\n                    stmt.close();\n                } catch (SQLException e) {\n                    log.error(\"Failed to close Statement\", e);\n                }\n            }\n        }","sourceCodeStart":153,"sourceCodeEnd":189,"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#L153-L189","documentation":"MySqlUtils.skipReadAndSortSampleData samples a column's values during chunk planning and throws InterruptedException when it detects Thread.currentThread().isInterrupted() mid-scan. The library throws this to abort long sampling scans promptly when the task is being cancelled or the checkpoint/job is stopping, preserving interruption semantics.","triggerScenarios":"Calling skipReadAndSortSampleData when the snapshot task thread is interrupted: job cancelled via REST/CLI, checkpoint timeout leading to task cancel, or engine shutdown during the sampling scan of a large table.","commonSituations":"User cancels a slow snapshot job; sampling a very large table takes so long that the engine cancels the task; worker shutdown/restart; manual kill of the job while sampling is in progress.","solutions":["This is usually an intentional cancellation — confirm whether the job was cancelled and simply restart it if the cancel was unintended","For very large tables, tune chunk size / sampling rate so planning finishes faster and is less likely to be cancelled","Check checkpoint timeout settings; raise them if long sampling trips checkpoint timeouts that trigger cancellation","Ensure the thread interrupt isn't caused by a shutdown hook or watchdog; inspect worker logs at cancellation time"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    List<Object> samples = MySqlUtils.skipReadAndSortSampleData(jdbc, tableId, col, rate, rows);\n} catch (InterruptedException e) {\n    Thread.currentThread().interrupt(); // restore flag before returning/cancelling\n}","preventionTips":["Tune sampling rate/chunk size for large tables so planning completes quickly","Raise checkpoint timeout if sampling trips cancellations","Don't cancel jobs unless intended; interrupts are the designed abort path","Monitor worker restarts that interrupt in-flight sampling"],"tags":["mysql","cdc","interruption","sampling","cancellation"],"backgroundTag":"thread-interrupted","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}