{"record":{"id":"ca654dce9ffea6d9","repo":"apache/flink","slug":"source-fetch-execution-was-interrupted","errorCode":null,"errorMessage":"Source fetch execution was interrupted","messagePattern":"Source fetch execution was interrupted","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"warning","filePath":"flink-connectors/flink-connector-base/src/main/java/org/apache/flink/connector/base/source/reader/fetcher/FetchTask.java","lineNumber":74,"sourceCode":"        try {\n            if (!isWakenUp() && lastRecords == null) {\n                lastRecords = splitReader.fetch();\n            }\n\n            if (!isWakenUp()) {\n                // The order matters here. We must first put the last records into the queue.\n                // This ensures the handling of the fetched records is atomic to wakeup.\n                if (elementsQueue.put(fetcherIndex, lastRecords)) {\n                    if (!lastRecords.finishedSplits().isEmpty()) {\n                        // The callback does not throw InterruptedException.\n                        splitFinishedCallback.accept(lastRecords.finishedSplits());\n                    }\n                    lastRecords = null;\n                }\n            }\n        } catch (InterruptedException e) {\n            // this should only happen on shutdown\n            throw new IOException(\"Source fetch execution was interrupted\", e);\n        } finally {\n            // clean up the potential wakeup effect. It is possible that the fetcher is waken up\n            // after the clean up. In that case, either the wakeup flag will be set or the\n            // running thread will be interrupted. The next invocation of run() will see that and\n            // just skip.\n            if (isWakenUp()) {\n                wakeup = false;\n            }\n        }\n        // The return value of fetch task does not matter.\n        return true;\n    }\n\n    @Override\n    public void wakeUp() {\n        // Set the wakeup flag first.\n        wakeup = true;\n        if (lastRecords == null) {","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-connectors/flink-connector-base/src/main/java/org/apache/flink/connector/base/source/reader/fetcher/FetchTask.java#L56-L92","documentation":"FetchTask#run wraps an InterruptedException in an IOException with the note 'this should only happen on shutdown'. The fetch thread (running SplitReader#fetch or the queue put) was interrupted, which is the normal cancellation/cleanup path, but it is surfaced as an exception so the SplitFetcher records it.","triggerScenarios":"The SplitFetcher thread is interrupted during splitReader.fetch() or during elementsQueue.put(...). Happens during source close, task cancellation, or failover when the framework interrupts the fetcher to stop it.","commonSituations":"Job cancellation while a fetch is in progress; source close timeout triggering thread interruption; failover of the task. Generally expected and benign during shutdown.","solutions":["Treat this as expected during cancellation/close; if seen during normal operation, investigate who interrupted the fetch thread.","Ensure you are not calling Thread#interrupt on the SplitFetcher thread from user code or a misbehaving SplitReader.","If it recurs outside shutdown, verify the SplitReader handles interruptions cleanly rather than propagating them.","Check that the source is not being closed with too short a timeout that forces interruption."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Framework-level: this is expected during shutdown. In a custom SplitReader:\npublic RecordsWithSplitIds<E> fetch() throws IOException {\n    try {\n        return splitReader.fetch();\n    } catch (IOException e) {\n        if (Thread.currentThread().isInterrupted() && e.getMessage().contains(\"interrupted\")) {\n            // shutdown path; stop gracefully\n            return null;\n        }\n        throw e;\n    }\n}","preventionTips":["Never interrupt the SplitFetcher thread from user code.","During cancellation, let the framework's close path handle interruption.","Treat this message during shutdown as benign noise, not a data bug."],"tags":["fetcher","interruption","shutdown","flink-source"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}