apache/seatunnel · critical · SeaTunnelException

Get connection failed after retry times

Error message

Get connection failed after retry times

What it means

After exhausting all connectRetryTimes attempts of dataSource.getConnection() each failing with SQLException, JdbcConnectionFactory.connect throws SeaTunnelException with this message (wrapping the last SQLException). It means no JDBC connection could be established within the configured retry budget.

Source

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

                        .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. Verify host, port, database name, username and password in the CDC source config; test with a plain JDBC client
  2. Check network/firewall/security-group rules between SeaTunnel worker and the database
  3. Check database-side limits (max_connections, memory) and server logs for rejected connections
  4. Increase connect.max-retries / retry tolerances if failures are transient, then restart the job

Example fix

// before
"hostname" = "localhost"
"port" = "3307"        // wrong port -> all retries fail
// after
"hostname" = "db-host"
"port" = "3306"        // correct; connection established
Defensive patterns

Strategy: retry

Validate before calling

// validate JDBC connectivity with a test query before launching the job
try (var c = DriverManager.getConnection(url, user, pass)) { c.isValid(5); }

Try / catch

try {
    connection = jdbcConnectionFactory.connect();
} catch (SeaTunnelException e) {
    LOG.error("CDC DB unreachable after retries: {}", e.getCause() == null ? e : e.getCause().getMessage());
    // alert / fail the deployment pipeline
}

Prevention

When it happens

Trigger: All retry attempts of dataSource.getConnection() fail (e.g. final attempt also throws), typically after connect.max-retries attempts with 300ms sleeps.

Common situations: Database host unreachable (wrong host/port, firewall), bad username/password, DB at max_connections, TLS mismatch, or the DB briefly down during job startup.

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/be8b02e4dea33857. Report an issue: GitHub.