{"record":{"id":"d18b080547ac9566","repo":"apache/seatunnel","slug":"failed-to-release-error-sink-classloader-for-jobid","errorCode":null,"errorMessage":"Failed to release error sink classloader for jobId={}, pluginName={}, jars={}","messagePattern":"Failed to release error sink classloader for jobId=(.+?), pluginName=(.+?), jars=(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/task/error/DefaultErrorSinkWriter.java","lineNumber":697,"sourceCode":"        }\n    }\n\n    private void releaseErrorSinkClassLoaderIfNeeded() {\n        if (classLoaderReleased) {\n            return;\n        }\n        List<URL> jars = this.errorSinkPluginJars;\n        if (jars == null || jars.isEmpty()) {\n            classLoaderReleased = true;\n            return;\n        }\n        try {\n            classLoaderService.releaseClassLoader(jobId, jars);\n        } catch (Throwable e) {\n            if (e instanceof Error) {\n                throw (Error) e;\n            }\n            log.warn(\n                    \"Failed to release error sink classloader for jobId={}, pluginName={}, jars={}\",\n                    jobId,\n                    sinkConfig.getPluginName(),\n                    jars,\n                    e);\n        } finally {\n            classLoaderReleased = true;\n            errorSinkPluginJars = null;\n            errorSinkClassLoader = null;\n        }\n    }\n\n    private SeaTunnelRowType buildErrorRowType() {\n        List<String> fieldNames = new ArrayList<>();\n        List<SeaTunnelDataType<?>> fieldTypes = new ArrayList<>();\n\n        fieldNames.add(\"error_stage\");\n        fieldTypes.add(BasicType.STRING_TYPE);","sourceCodeStart":679,"sourceCodeEnd":715,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/task/error/DefaultErrorSinkWriter.java#L679-L715","documentation":"DefaultErrorSinkWriter may load the error-sink plugin with an isolated classloader obtained from the engine's ClassLoaderService. On release, classLoaderService.releaseClassLoader(jobId, jars) threw; Errors are rethrown, but any other Throwable is logged as this warning and cleanup state is still reset. A leaked classloader can retain plugin jars in memory (metaspace pressure) but does not fail the task.","triggerScenarios":"releaseClassLoader throws for the given jobId+jars — e.g. the classloader was never cached for those jars, the cache entry was already released (double release from both close() and ensureInitialized() paths), or the service throws an internal exception.","commonSituations":"Job cleanup running twice (task retry + final close); engine restart/cleanup racing classloader release; custom ClassLoaderService implementations with non-idempotent release; jar list mutated between acquisition and release.","solutions":["Check for duplicate close/release calls in your lifecycle (task retry + close) — this warning then reflects a benign double release.","Verify the ClassLoaderService implementation's release is idempotent and matches how the loader was acquired.","Confirm the jar URLs used at release exactly match those used at acquisition.","Watch metaspace usage; repeated warnings may indicate classloader leaks across jobs."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n    classLoaderService.releaseClassLoader(jobId, jars);\n} catch (Throwable e) {\n    if (e instanceof Error) throw (Error) e;\n    LOG.warn(\"classloader release failed; possible leak\", e);\n}","preventionTips":["Ensure release is called exactly once per acquisition (guard with a released flag)","Pass the exact same jar URL list used at acquisition","Use idempotent ClassLoaderService implementations"],"tags":["classloader","resource-leak","cleanup"],"backgroundTag":"resource-cleanup-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"}