{"record":{"id":"36a84c53db3cf7dc","repo":"apache/seatunnel","slug":"thread-interrupted-36a84c","errorCode":null,"errorMessage":"Thread interrupted","messagePattern":"Thread interrupted","errorType":"exception","errorClass":"InterruptedException","httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/mysql/MysqlDialect.java","lineNumber":186,"sourceCode":"                            \"SELECT %s FROM %s\",\n                            quoteIdentifier(columnName), tableIdentifier(table.getTablePath()));\n        }\n\n        try (Statement stmt =\n                connection.createStatement(\n                        ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)) {\n            stmt.setFetchSize(Integer.MIN_VALUE);\n            try (ResultSet rs = stmt.executeQuery(sampleQuery)) {\n                int count = 0;\n                List<Object> results = new ArrayList<>();\n\n                while (rs.next()) {\n                    count++;\n                    if (count % samplingRate == 0) {\n                        results.add(rs.getObject(1));\n                    }\n                    if (Thread.currentThread().isInterrupted()) {\n                        throw new InterruptedException(\"Thread interrupted\");\n                    }\n                }\n                Object[] resultsArray = results.toArray();\n                Arrays.sort(resultsArray);\n                return resultsArray;\n            }\n        }\n    }\n\n    @Override\n    public Long approximateRowCntStatement(Connection connection, JdbcSourceTable table)\n            throws SQLException {\n\n        // 1. If no query is configured, use TABLE STATUS.\n        // 2. If a query is configured but does not contain a WHERE clause and tablePath is\n        // configured , use TABLE STATUS.\n        // 3. If a query is configured with a WHERE clause, or a query statement is configured but\n        // tablePath is TablePath.DEFAULT, use COUNT(*).","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/mysql/MysqlDialect.java#L168-L204","documentation":"MysqlDialect.sampleDataFromColumn samples column values via a JDBC ResultSet to estimate split boundaries. During result iteration it checks Thread.currentThread().isInterrupted() and throws InterruptedException to abort sampling promptly when the task thread is interrupted (e.g. job cancel/checkpoint timeout). It is a cooperative-cancellation signal, not a data error.","triggerScenarios":"The sampling loop in sampleDataFromColumn is running and the worker thread's interrupt flag is set — typically SeaTunnel cancelling a SourceReader/task, job termination, or a caller thread being interrupted while blocking on the JDBC query.","commonSituations":"User cancels a running Zeta job while split enumeration is sampling a large table; checkpoint/restore timeout causes the coordinator to interrupt tasks; JVM shutdown hooks interrupt worker threads.","solutions":["No fix needed if caused by intentional job cancellation; the framework expects this abort.","If seen unexpectedly, check upstream for code that clears or sets interrupt status improperly (e.g. swallowing InterruptedException without restoring the flag).","Reduce sampling cost (smaller table sampling window / higher samplingRate) so cancellation is fast and races are less likely.","Catch InterruptedException in custom code around source enumeration and re-interrupt (Thread.currentThread().interrupt()) before retrying."],"exampleFix":"// before\ncatch (InterruptedException e) {\n    // swallowed\n}\n// after\ncatch (InterruptedException e) {\n    Thread.currentThread().interrupt();\n    throw new RuntimeException(\"Sampling interrupted\", e);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { dialect.sampleDataFromColumn(...); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(\"Split sampling cancelled\", e); }","preventionTips":["Never swallow InterruptedException without restoring the interrupt flag","Expect interruption during job cancel/checkpoint timeout and treat it as normal control flow","Keep sampling queries cheap so cancellation is fast"],"tags":["jdbc","mysql","interruption","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-14T11:17:12.474Z"}