{"record":{"id":"a34bb7bda61d757e","repo":"apache/seatunnel","slug":"failed-to-shutdown-mysql-abandoned-connection-clea","errorCode":null,"errorMessage":"Failed to shutdown MySQL abandoned connection cleanup thread (if present). jobId={}, pluginName={}","messagePattern":"Failed to shutdown MySQL abandoned connection cleanup thread \\(if present\\)\\. jobId=(.+?), pluginName=(.+?)","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":296,"sourceCode":"                        new RuntimeException(\n                                String.format(\n                                        \"Timed out waiting for error sink worker to close. jobId=%d, pluginName=%s\",\n                                        jobId, sinkConfig.getPluginName()));\n            } else {\n                // Worker thread stopped; close remaining resources.\n                closeWriterIfPossible();\n            }\n        } catch (Throwable e) {\n            closeEx = e;\n            log.warn(\"Failed to close error sink writer\", e);\n        } finally {\n            try {\n                shutdownMySqlAbandonedConnectionCleanupThreadIfPresent();\n            } catch (Throwable cleanupEx) {\n                if (cleanupEx instanceof Error) {\n                    throw (Error) cleanupEx;\n                }\n                log.warn(\n                        \"Failed to shutdown MySQL abandoned connection cleanup thread (if present). jobId={}, pluginName={}\",\n                        jobId,\n                        sinkConfig.getPluginName(),\n                        cleanupEx);\n                if (closeEx != null) {\n                    closeEx.addSuppressed(cleanupEx);\n                }\n            }\n            releaseErrorSinkClassLoaderIfNeeded();\n        }\n        if (closeEx != null && workerFailure != null) {\n            closeEx.addSuppressed(workerFailure);\n        }\n        if (closeEx != null) {\n            if (closeEx instanceof Exception) {\n                throw (Exception) closeEx;\n            }\n            throw new RuntimeException(closeEx);","sourceCodeStart":278,"sourceCodeEnd":314,"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#L278-L314","documentation":"During DefaultErrorSinkWriter.close(), the code attempts to shut down MySQL's AbandonedConnectionCleanupThread (if the MySQL driver loaded it) to avoid keeping threads/classloaders alive. If that cleanup throws a non-Error Throwable, this warning is logged and the exception is attached as suppressed to the primary close exception. It signals an incomplete shutdown, not a data-loss condition.","triggerScenarios":"close() calls shutdownMySqlAbandonedConnectionCleanupThreadIfPresent() and that reflection-based cleanup throws (e.g. driver class not on classpath, thread already terminated abnormally, security/reflective access restrictions).","commonSituations":"Error sink using a MySQL JDBC driver whose abandoned-connection cleanup thread is active; running on JDKs or with module restrictions blocking reflective access to the driver's thread; driver version differences changing cleanup internals.","solutions":["Upgrade the MySQL Connector/J to a version that manages the cleanup thread itself (5.1.45+).","Ensure the driver jar is present in the connector/plugin classpath so reflection succeeds.","Explicitly call AbandonedConnectionCleanupThread.checkedShutdown() / unwind thread before engine shutdown if embedding SeaTunnel.","Review the suppressed exception (cleanupEx) for the root cause and fix the underlying reflective-access or classpath problem."],"exampleFix":"// before: driver version with lingering cleanup thread\nmysql-connector-java-5.1.38.jar\n// after\nmysql-connector-java-8.0.33.jar // self-manages AbandonedConnectionCleanupThread","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    errorSinkWriter.close();\n} catch (Throwable t) {\n    // inspect suppressed exceptions for MySQL cleanup failures\n    for (Throwable s : t.getSuppressed()) log.warn(\"suppressed during close\", s);\n}","preventionTips":["Use MySQL Connector/J >= 5.1.45 which self-manages the cleanup thread.","Keep driver jars on the connector classpath so reflective cleanup works.","Avoid JVM module/SecurityManager settings that block reflective access to driver internals.","Treat this warning as non-fatal; check suppressed exceptions for root cause."],"tags":["mysql","jdbc","thread-cleanup","shutdown"],"backgroundTag":"resource-cleanup-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"}