{"record":{"id":"c158e1100447b504","repo":"apache/seatunnel","slug":"thread-interrupted-c158e1","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/JdbcDialect.java","lineNumber":417,"sourceCode":"            sampleQuery =\n                    String.format(\n                            \"SELECT %s FROM %s\",\n                            quoteIdentifier(columnName), tableIdentifier(table.getTablePath()));\n        }\n\n        try (PreparedStatement stmt = creatPreparedStatement(connection, sampleQuery, fetchSize)) {\n            log.info(String.format(\"Split Chunk, approximateRowCntStatement: %s\", sampleQuery));\n            try (ResultSet rs = stmt.executeQuery()) {\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    /**\n     * Query the maximum value of the next chunk, and the next chunk must be greater than or equal\n     * to <code>includedLowerBound</code> value [min_1, max_1), [min_2, max_2),... [min_n, null).\n     * Each time this method is called it will return max1, max2...\n     *\n     * @param connection JDBC connection.\n     * @param table table info.\n     * @param columnName column name.\n     * @param chunkSize chunk size.","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/JdbcDialect.java#L399-L435","documentation":"JdbcDialect.sampleDataFromColumn samples values of a column (used e.g. to pick split keys) and checks Thread interruption inside the ResultSet loop, throwing InterruptedException('Thread interrupted') when the current thread has been interrupted. This is a cooperative-cancellation signal: the sampling query is being aborted (job cancel/stop or task shutdown) while reading rows.","triggerScenarios":"The thread running the sampling query gets interrupted mid rs.next() iteration — typically during job cancellation, checkpoint/task cancellation, or shutdown — after at least `count % samplingRate == 0` iterations started.","commonSituations":"Cancelling a long-running SeaTunnel job while split enumeration is sampling large tables; job manager timeouts interrupting workers; manual kill/restart of the cluster during startup.","solutions":["No fix needed if intentional cancellation — treat as cancellation, restore the interrupt flag and stop gracefully","If unexpected, find who interrupted the thread (job cancellation logs) and address the upstream timeout/shutdown trigger","Reduce sampling cost (raise samplingRate, index the sampled column) so sampling completes before cancellations occur","Retry the job; this error is transient and tied to interruption, not data"],"exampleFix":"// before\ntry {\n    results = dialect.sampleDataFromColumn(...);\n} catch (InterruptedException e) { /* swallow */ }\n// after\ntry {\n    results = dialect.sampleDataFromColumn(...);\n} catch (InterruptedException e) {\n    Thread.currentThread().interrupt(); // restore flag\n    throw new SeaTunnelRuntimeException(..., \"sampling cancelled\", e);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    Object[] sample = dialect.sampleDataFromColumn(conn, table, column, samplingRate);\n} catch (InterruptedException e) {\n    Thread.currentThread().interrupt(); // restore cancel status\n    throw new CancellationException(\"Sampling interrupted by job cancellation\");\n}","preventionTips":["Expect interruption during job cancel/stop; always restore the interrupt flag","Keep sampling cheap: indexed split columns and sensible samplingRate","Avoid killing workers mid-snapshot; use graceful stop","Monitor cancellation timeouts that interrupt enumeration threads"],"tags":["jdbc","interruption","cancellation","sampling"],"backgroundTag":"request-timeout","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"}