{"record":{"id":"4ec42482b97cadf7","repo":"apache/seatunnel","slug":"thread-interrupted-4ec424","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/oracle/OracleDialect.java","lineNumber":363,"sourceCode":"        } else {\n            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            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    @Override\n    public void applySchemaChange(\n            Connection connection, TablePath tablePath, AlterTableAddColumnEvent event)\n            throws SQLException {\n        List<String> ddlSQL = new ArrayList<>();\n        ddlSQL.add(buildUpdateColumnSQL(connection, tablePath, event));\n\n        if (event.getColumn().getComment() != null) {\n            ddlSQL.add(buildUpdateColumnCommentSQL(tablePath, event.getColumn()));","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/oracle/OracleDialect.java#L345-L381","documentation":"OracleDialect.sampleDataFromColumn samples column values by iterating a ResultSet and throws InterruptedException if the worker thread is interrupted mid-sampling. This honors cooperative cancellation so long-running sampling queries can be aborted promptly instead of blocking. The interruption check runs every row inside the rs.next() loop.","triggerScenarios":"The task thread executing sampleDataFromColumn is interrupted (job cancel, checkpoint timeout kill, shutdown) while the sampling ResultSet is being iterated.","commonSituations":"User cancels a running SeaTunnel job; engine shuts down workers during a large-table split enumeration; upstream cancellation propagates to the thread blocked on a slow Oracle sampling query.","solutions":["Treat it as expected cancellation: catch InterruptedException, restore the interrupt flag (Thread.currentThread().interrupt()), and abort the split enumeration cleanly","Investigate why the thread was interrupted (job cancelled, worker shutdown, checkpoint timeout) if cancellation was not intended","Reduce sampling cost (raise samplingRate or limit the query) so sampling finishes quickly and is less likely to be interrupted","Ensure connection/statement resources are closed in finally/try-with-resources when propagating the exception"],"exampleFix":"// before\ntry {\n    Object[] sample = dialect.sampleDataFromColumn(conn, table, column, samplingRate);\n} catch (InterruptedException e) {\n    // swallowed, lost cancellation signal\n}\n// after\ntry {\n    Object[] sample = dialect.sampleDataFromColumn(conn, table, column, samplingRate);\n} catch (InterruptedException e) {\n    Thread.currentThread().interrupt();\n    throw new RuntimeException(\"Sampling cancelled for column \" + column, e);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    dialect.sampleDataFromColumn(conn, table, column, rate);\n} catch (InterruptedException e) {\n    Thread.currentThread().interrupt();\n    throw new CancellationException(\"Column sampling interrupted\");\n}","preventionTips":["Never swallow InterruptedException; always restore the interrupt flag","Avoid cancelling jobs during split enumeration when possible","Keep sampling queries cheap (high samplingRate) to shorten interruptible windows","Check job logs for why cancellation occurred"],"tags":["jdbc","oracle","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"}