{"record":{"id":"f56dce0f90fad044","repo":"apache/seatunnel","slug":"failed-to-get-connection-interrupted-while-doing","errorCode":null,"errorMessage":"Failed to get connection, interrupted while doing another attempt","messagePattern":"Failed to get connection, interrupted while doing another attempt","errorType":"exception","errorClass":"SeaTunnelException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/relational/connection/JdbcConnectionFactory.java","lineNumber":71,"sourceCode":"                new ConnectionPoolId(\n                        sourceConfig.getHostname(),\n                        sourceConfig.getPort(),\n                        sourceConfig.getUsername());\n\n        HikariDataSource dataSource =\n                JdbcConnectionPools.getInstance(jdbcConnectionPoolFactory)\n                        .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":53,"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#L53-L86","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Fix the underlying database connectivity problem so retries do not linger (network, firewall, max_connections, credentials)","Re-run the job once the database is reachable; the interrupt itself was likely an intentional shutdown","Avoid cancelling the job repeatedly while connection acquisition is in flight; increase connect.max-retries so attempts succeed sooner","If interruptions happen without user cancellation, check for overly aggressive cluster shutdown/timeout settings"],"exampleFix":"// before\n// job cancelled while DB unreachable -> interrupted during retry sleep\nurl = \"jdbc:mysql://localhost:3306\"  // DB down\n// after\n// fix DB reachability first\nurl = \"jdbc:mysql://db-host:3306\"  // reachable; connect succeeds on first attempt","handlingStrategy":"retry","validationCode":"// verify reachability before submitting\nnc -vz $DB_HOST $DB_PORT","typeGuard":null,"tryCatchPattern":"try {\n    connection = jdbcConnectionFactory.connect();\n} catch (SeaTunnelException e) {\n    if (e.getCause() instanceof InterruptedException) {\n        // job was interrupted during retry; treat as shutdown, don't auto-retry here\n    }\n}","preventionTips":["Avoid cancelling jobs while connection retries are in flight","Resolve DB connectivity before job submission so retry sleeps are never reached","Monitor job shutdown behavior to prevent spurious interrupts"],"tags":["jdbc","connection","retry","interrupted","cancellation"],"backgroundTag":"request-timeout","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"}