{"record":{"id":"be8b02e4dea33857","repo":"apache/seatunnel","slug":"get-connection-failed-after-retry-times","errorCode":null,"errorMessage":"Get connection failed after retry times","messagePattern":"Get connection failed after retry times","errorType":"exception","errorClass":"SeaTunnelException","httpStatus":null,"severity":"critical","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/relational/connection/JdbcConnectionFactory.java","lineNumber":78,"sourceCode":"                        .getOrCreateConnectionPool(connectionPoolId, sourceConfig);\n\n        int i = 0;\n        while (i < connectRetryTimes) {\n            try {\n                return dataSource.getConnection();\n            } catch (SQLException e) {\n                if (i < connectRetryTimes - 1) {\n                    try {\n                        Thread.sleep(300);\n                    } catch (InterruptedException ie) {\n                        throw new SeaTunnelException(\n                                \"Failed to get connection, interrupted while doing another attempt\",\n                                ie);\n                    }\n                    LOG.warn(\"Get connection failed, retry times {}\", i + 1);\n                } else {\n                    LOG.error(\"Get connection failed after retry {} times\", i + 1);\n                    throw new SeaTunnelException(e);\n                }\n            }\n            i++;\n        }\n        return dataSource.getConnection();\n    }\n}\n","sourceCodeStart":60,"sourceCodeEnd":86,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/relational/connection/JdbcConnectionFactory.java#L60-L86","documentation":"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.","triggerScenarios":"All retry attempts of dataSource.getConnection() fail (e.g. final attempt also throws), typically after connect.max-retries attempts with 300ms sleeps.","commonSituations":"Database host unreachable (wrong host/port, firewall), bad username/password, DB at max_connections, TLS mismatch, or the DB briefly down during job startup.","solutions":["Verify host, port, database name, username and password in the CDC source config; test with a plain JDBC client","Check network/firewall/security-group rules between SeaTunnel worker and the database","Check database-side limits (max_connections, memory) and server logs for rejected connections","Increase connect.max-retries / retry tolerances if failures are transient, then restart the job"],"exampleFix":"// before\n\"hostname\" = \"localhost\"\n\"port\" = \"3307\"        // wrong port -> all retries fail\n// after\n\"hostname\" = \"db-host\"\n\"port\" = \"3306\"        // correct; connection established","handlingStrategy":"retry","validationCode":"// validate JDBC connectivity with a test query before launching the job\ntry (var c = DriverManager.getConnection(url, user, pass)) { c.isValid(5); }","typeGuard":null,"tryCatchPattern":"try {\n    connection = jdbcConnectionFactory.connect();\n} catch (SeaTunnelException e) {\n    LOG.error(\"CDC DB unreachable after retries: {}\", e.getCause() == null ? e : e.getCause().getMessage());\n    // alert / fail the deployment pipeline\n}","preventionTips":["Verify host/port/credentials with a JDBC client before running the job","Open firewall/security-group paths from workers to the database","Keep connect.max-retries sized for transient outages","Watch database max_connections and grant correct credentials"],"tags":["jdbc","connection","retry-exhausted","database"],"backgroundTag":"connection-refused","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}