apache/seatunnel · warning

Failed to shutdown MySQL abandoned connection cleanup thread

Error message

Failed to shutdown MySQL abandoned connection cleanup thread (if present). jobId={}, pluginName={}

What it means

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.

Source

Thrown at seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/task/error/DefaultErrorSinkWriter.java:296

                        new RuntimeException(
                                String.format(
                                        "Timed out waiting for error sink worker to close. jobId=%d, pluginName=%s",
                                        jobId, sinkConfig.getPluginName()));
            } else {
                // Worker thread stopped; close remaining resources.
                closeWriterIfPossible();
            }
        } catch (Throwable e) {
            closeEx = e;
            log.warn("Failed to close error sink writer", e);
        } finally {
            try {
                shutdownMySqlAbandonedConnectionCleanupThreadIfPresent();
            } catch (Throwable cleanupEx) {
                if (cleanupEx instanceof Error) {
                    throw (Error) cleanupEx;
                }
                log.warn(
                        "Failed to shutdown MySQL abandoned connection cleanup thread (if present). jobId={}, pluginName={}",
                        jobId,
                        sinkConfig.getPluginName(),
                        cleanupEx);
                if (closeEx != null) {
                    closeEx.addSuppressed(cleanupEx);
                }
            }
            releaseErrorSinkClassLoaderIfNeeded();
        }
        if (closeEx != null && workerFailure != null) {
            closeEx.addSuppressed(workerFailure);
        }
        if (closeEx != null) {
            if (closeEx instanceof Exception) {
                throw (Exception) closeEx;
            }
            throw new RuntimeException(closeEx);

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Upgrade the MySQL Connector/J to a version that manages the cleanup thread itself (5.1.45+).
  2. Ensure the driver jar is present in the connector/plugin classpath so reflection succeeds.
  3. Explicitly call AbandonedConnectionCleanupThread.checkedShutdown() / unwind thread before engine shutdown if embedding SeaTunnel.
  4. Review the suppressed exception (cleanupEx) for the root cause and fix the underlying reflective-access or classpath problem.

Example fix

// before: driver version with lingering cleanup thread
mysql-connector-java-5.1.38.jar
// after
mysql-connector-java-8.0.33.jar // self-manages AbandonedConnectionCleanupThread
Defensive patterns

Strategy: try-catch

Try / catch

try {
    errorSinkWriter.close();
} catch (Throwable t) {
    // inspect suppressed exceptions for MySQL cleanup failures
    for (Throwable s : t.getSuppressed()) log.warn("suppressed during close", s);
}

Prevention

When it happens

Trigger: close() calls shutdownMySqlAbandonedConnectionCleanupThreadIfPresent() and that reflection-based cleanup throws (e.g. driver class not on classpath, thread already terminated abnormally, security/reflective access restrictions).

Common situations: 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.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/a34bb7bda61d757e. Report an issue: GitHub.