apache/seatunnel · warning

Connection close failed.

Error message

Connection close failed.

What it means

A WARN log in XaFacadeImplAutoLoad.closeConnection() — the wrapper that closes the facade swallows any SQLException raised by close() and only logs 'Connection close failed.' It exists so sink cleanup (e.g. on checkpoint abort or task shutdown) never throws. The error indicates the XA connection could not be cleanly released; the job continues or terminates without failing on this.

Solutions

  1. Check DB connectivity and firewall/idle timeouts to avoid stale sessions at close time
  2. Inspect the logged SQLException cause for the real problem (auth, network, driver)
  3. Ignore if it occurs only at job shutdown after a network break — resources are reclaimed eventually
  4. Ensure the JDBC driver version matches the DB server version
Defensive patterns

Strategy: try-catch

Validate before calling

// Health-check the DB before job start/shutdown
try (Connection c = DriverManager.getConnection(url, user, pass)) {
    c.isValid(5);
}

Try / catch

try {
    xaFacade.closeConnection();
} catch (Exception e) {
    LOG.warn("Connection close failed (swallowed by facade)", e);
}

Prevention

When it happens

Trigger: closeConnection() invokes close() and the underlying connection.close() throws SQLException (broken network, DB session already terminated, driver error).

Common situations: Sink close during job cancellation with a dead DB; DB failover/kill of the session before shutdown; idle-connection timeout.

Understand the failure class

Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.

Related errors


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

Appendix: source

Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/xa/XaFacadeImplAutoLoad.java:167

    @Override
    public boolean isConnectionValid() throws SQLException {
        return isOpen() && connection.isValid(connection.getNetworkTimeout());
    }

    @Override
    public Connection getOrEstablishConnection() throws SQLException {
        if (!isOpen()) {
            open();
        }
        return connection;
    }

    @Override
    public void closeConnection() {
        try {
            close();
        } catch (SQLException e) {
            LOG.warn("Connection close failed.", e);
        }
    }

    @Override
    public Connection reestablishConnection() {
        throw new JdbcConnectorException(
                CommonErrorCodeDeprecated.UNSUPPORTED_OPERATION,
                "The instance failed to implement this method");
    }

    @Override
    public void start(Xid xid) {
        execute(Command.fromRunnable("start", xid, () -> xaResource.start(xid, TMNOFLAGS)));
    }

    @Override
    public void endAndPrepare(Xid xid) {
        execute(Command.fromRunnable("end", xid, () -> xaResource.end(xid, XAResource.TMSUCCESS)));

View on GitHub (pinned to cf67b549a7)