{"record":{"id":"86b47b47ed6cf9ec","repo":"apache/seatunnel","slug":"failed-to-close-file-discovery-resources-for-plugi","errorCode":null,"errorMessage":"Failed to close file discovery resources for plugin {}","messagePattern":"Failed to close file discovery resources for plugin (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/config/BaseFileSourceConfig.java","lineNumber":125,"sourceCode":"\n    public List<String> getFilePathsForSplitEnumerator() {\n        if (fileDiscoveryDeferred) {\n            ReadStrategy discoveryReadStrategy =\n                    ReadStrategyFactory.of(baseFileSourceConfig, getHadoopConfig());\n            try {\n                return discoverFilePaths(discoveryReadStrategy);\n            } finally {\n                closeDiscoveryReadStrategy(discoveryReadStrategy);\n            }\n        }\n        return filePaths;\n    }\n\n    private void closeDiscoveryReadStrategy(ReadStrategy discoveryReadStrategy) {\n        try {\n            discoveryReadStrategy.close();\n        } catch (IOException e) {\n            log.warn(\"Failed to close file discovery resources for plugin {}\", getPluginName(), e);\n        }\n    }\n\n    private List<String> discoverFilePaths() {\n        return discoverFilePaths(readStrategy);\n    }\n\n    private List<String> discoverFilePaths(ReadStrategy discoveryReadStrategy) {\n        String rootPath = baseFileSourceConfig.get(FileBaseSourceOptions.FILE_PATH);\n        long startTime = System.currentTimeMillis();\n        try {\n            List<String> discoveredFilePaths = discoveryReadStrategy.getFileNamesByPath(rootPath);\n            log.info(\n                    \"File source discovery finished: plugin={}, path={}, files={}, cost={}ms\",\n                    getPluginName(),\n                    safeDiscoveryRootContext,\n                    discoveredFilePaths.size(),\n                    System.currentTimeMillis() - startTime);","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/config/BaseFileSourceConfig.java#L107-L143","documentation":"A WARN from BaseFileSourceConfig.closeDiscoveryReadStrategy: the temporary ReadStrategy used only for file discovery could not be closed (its close() threw an IOException). Split enumeration already produced file paths; only underlying resources (filesystem handles, HDFS clients) of the discovery strategy may leak.","triggerScenarios":"getFilePathsForSplitEnumerator creates a throwaway discovery ReadStrategy, calls it, then closes it in a finally; close() throws IOException because the Hadoop/S3 filesystem was already closed, credentials were revoked, or the remote store returned an I/O error during cleanup.","commonSituations":"HDFS NameNode restarts or S3 throttling during job startup; Kerberos token expiry between discovery and close; sharing filesystem caches that another component closed concurrently.","solutions":["Check filesystem stability and credentials at job start; rerun the job once the cluster/storage is healthy","Ensure the storage plugin (hadoop-s3, oss, etc.) credentials are valid for the whole enumeration window","If it recurs, verify the connector version's ReadStrategy.close() implementation for known cleanup bugs","Treat as non-fatal: enumeration results are already complete"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// preflight: check storage reachable with job credentials\n// hadoop fs -ls hdfs://nn:8020/base/path  (or aws s3 ls s3://bucket/path)","typeGuard":null,"tryCatchPattern":"// enumeration already succeeded; only cleanup failed.\n// treat as informational; escalate only if job start also throws IOException","preventionTips":["Ensure keytab/credentials stay valid through the whole enumeration window","Run a preflight read (list files) with the same user before submitting the job","Keep HDFS/S3 endpoints stable during job launch (avoid rolling restarts then)"],"tags":["file","hadoop","resource-leak"],"backgroundTag":"file-read-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}