{"record":{"id":"7482ef63f8d263c9","repo":"apache/seatunnel","slug":"failed-to-close-the-source-reader-in-ms-there","errorCode":null,"errorMessage":"Failed to close the source reader in {} ms. There are still {} split fetchers running","messagePattern":"Failed to close the source reader in (.+?) ms\\. There are still (.+?) split fetchers running","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-common/src/main/java/org/apache/seatunnel/connectors/seatunnel/common/source/reader/fetcher/SplitFetcherManager.java","lineNumber":136,"sourceCode":"        Iterator<Map.Entry<Integer, SplitFetcher<E, SplitT>>> iter = fetchers.entrySet().iterator();\n        while (iter.hasNext()) {\n            Map.Entry<Integer, SplitFetcher<E, SplitT>> entry = iter.next();\n            SplitFetcher<E, SplitT> fetcher = entry.getValue();\n            if (fetcher.isIdle()) {\n                log.info(\"Closing splitFetcher {} because it is idle.\", entry.getKey());\n                fetcher.shutdown();\n                iter.remove();\n            }\n        }\n        return fetchers.isEmpty();\n    }\n\n    public synchronized void close(long timeoutMs) throws Exception {\n        closed = true;\n        fetchers.values().forEach(SplitFetcher::shutdown);\n        executors.shutdown();\n        if (!executors.awaitTermination(timeoutMs, TimeUnit.MILLISECONDS)) {\n            log.warn(\n                    \"Failed to close the source reader in {} ms. There are still {} split fetchers running\",\n                    timeoutMs,\n                    fetchers.size());\n        }\n    }\n\n    public void checkErrors() {\n        if (uncaughtFetcherException.get() != null) {\n            throw new RuntimeException(\n                    \"One or more fetchers have encountered exception\",\n                    uncaughtFetcherException.get());\n        }\n    }\n}\n","sourceCodeStart":118,"sourceCodeEnd":151,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-common/src/main/java/org/apache/seatunnel/connectors/seatunnel/common/source/reader/fetcher/SplitFetcherManager.java#L118-L151","documentation":"SplitFetcherManager.close shuts down all split fetchers and awaits executor termination within timeoutMs. If fetchers do not finish in time, this warning reports how many fetchers are still running. Data may still be in flight and the source reader was not cleanly closed — often a symptom of a fetcher blocked on a slow network read or a task that ignores interrupts.","triggerScenarios":"Calling sourceReader.close(timeoutMs) (e.g. during job cancellation/checkpoint) while fetchers are blocked in long network I/O against the upstream source (Kafka, file reads, etc.) exceeding the timeout.","commonSituations":"Slow or hung upstream source connection; timeoutMs configured too small; fetcher stuck in a blocking poll that ignores shutdown signal; network partition during job teardown.","solutions":["Increase the close timeout passed to close(timeoutMs) so slow fetchers can finish","Investigate why fetchers hang: check network connectivity/latency to the source and source-side consumer lag","Check that the SplitFetcher loop reacts promptly to shutdown (bounded blocking calls, interruptible I/O); fix the reader/fetcher implementation if it blocks indefinitely"],"exampleFix":"// before\nsplitFetcherManager.close(1000);\n// after\nsplitFetcherManager.close(60000); // give fetchers time to drain","handlingStrategy":"try-catch","validationCode":"// Ensure fetchers are idle before closing\nif (!splitFetcherManager.isIdle()) { drainOrCancelSplitsFirst(); }","typeGuard":null,"tryCatchPattern":"try {\n  splitFetcherManager.close(timeoutMs);\n} catch (Exception e) {\n  log.warn(\"Source reader close incomplete; fetchers may still be running\", e);\n  // optionally: force shutdown or escalate\n}","preventionTips":["Use generous close timeouts relative to worst-case fetch latency","Monitor source network health; hung fetchers usually mean hung connections","Ensure custom readers use interruptible/bounded blocking I/O"],"tags":["shutdown","timeout","source-reader","threads"],"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"}