apache/seatunnel · error · SeaTunnelException

Failed to get connection, interrupted while doing another at

Error message

Failed to get connection, interrupted while doing another attempt

What it means

JdbcConnectionFactory.connect retries acquiring a JDBC connection from the DataSource up to connectRetryTimes. If a retry attempt fails with SQLException and the intervening Thread.sleep is interrupted (InterruptedException), it wraps and rethrows as SeaTunnelException with this message, abandoning further retries.

Source

Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/relational/connection/JdbcConnectionFactory.java:71

                new ConnectionPoolId(
                        sourceConfig.getHostname(),
                        sourceConfig.getPort(),
                        sourceConfig.getUsername());

        HikariDataSource dataSource =
                JdbcConnectionPools.getInstance(jdbcConnectionPoolFactory)
                        .getOrCreateConnectionPool(connectionPoolId, sourceConfig);

        int i = 0;
        while (i < connectRetryTimes) {
            try {
                return dataSource.getConnection();
            } catch (SQLException e) {
                if (i < connectRetryTimes - 1) {
                    try {
                        Thread.sleep(300);
                    } catch (InterruptedException ie) {
                        throw new SeaTunnelException(
                                "Failed to get connection, interrupted while doing another attempt",
                                ie);
                    }
                    LOG.warn("Get connection failed, retry times {}", i + 1);
                } else {
                    LOG.error("Get connection failed after retry {} times", i + 1);
                    throw new SeaTunnelException(e);
                }
            }
            i++;
        }
        return dataSource.getConnection();
    }
}

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Fix the underlying database connectivity problem so retries do not linger (network, firewall, max_connections, credentials)
  2. Re-run the job once the database is reachable; the interrupt itself was likely an intentional shutdown
  3. Avoid cancelling the job repeatedly while connection acquisition is in flight; increase connect.max-retries so attempts succeed sooner
  4. If interruptions happen without user cancellation, check for overly aggressive cluster shutdown/timeout settings

Example fix

// before
// job cancelled while DB unreachable -> interrupted during retry sleep
url = "jdbc:mysql://localhost:3306"  // DB down
// after
// fix DB reachability first
url = "jdbc:mysql://db-host:3306"  // reachable; connect succeeds on first attempt
Defensive patterns

Strategy: retry

Validate before calling

// verify reachability before submitting
nc -vz $DB_HOST $DB_PORT

Try / catch

try {
    connection = jdbcConnectionFactory.connect();
} catch (SeaTunnelException e) {
    if (e.getCause() instanceof InterruptedException) {
        // job was interrupted during retry; treat as shutdown, don't auto-retry here
    }
}

Prevention

When it happens

Trigger: A SQLException occurs on a non-final retry, then the worker thread sleeping 300ms between attempts receives an interrupt (task cancel/shutdown, Thread.interrupt from engine stop).

Common situations: Zeta engine job cancellation or node shutdown while a CDC source is stuck retrying a dead/overloaded database connection; operator kills the job during retry backoff.

Understand the failure class

Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.

Related errors


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