{"record":{"id":"707f80a5c7304187","repo":"apache/seatunnel","slug":"jdbc-connection-close-failed-707f80","errorCode":null,"errorMessage":"JDBC connection close failed.","messagePattern":"JDBC connection close failed\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/dsql/DdsqlJdbcConnectionPoolProviderProxy.java","lineNumber":66,"sourceCode":"    public boolean isConnectionValid() throws SQLException {\n        return poolManager.containsConnection(queueIndex)\n                && poolManager\n                        .getConnection(queueIndex)\n                        .isValid(jdbcConfig.getConnectionCheckTimeoutSeconds());\n    }\n\n    @Override\n    public Connection getOrEstablishConnection() {\n        return poolManager.getConnection(queueIndex);\n    }\n\n    @Override\n    public void closeConnection() {\n        if (poolManager.containsConnection(queueIndex)) {\n            try {\n                poolManager.remove(queueIndex).close();\n            } catch (SQLException e) {\n                log.warn(\"JDBC connection close failed.\", e);\n            }\n        }\n    }\n\n    @Override\n    public Connection reestablishConnection() {\n        closeConnection();\n        return getOrEstablishConnection();\n    }\n}\n","sourceCodeStart":48,"sourceCodeEnd":77,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/dsql/DdsqlJdbcConnectionPoolProviderProxy.java#L48-L77","documentation":"A log warning in DdsqlJdbcConnectionPoolProviderProxy.closeConnection: closing a pooled JDBC connection (via poolManager.remove(queueIndex).close()) threw a SQLException. The connection is discarded from the pool anyway; this is a cleanup-path warning and does not fail the running operation. Typically the connection was already dead (stale/broken) when the pool tried to close it.","triggerScenarios":"closeConnection() called (e.g. from reestablishConnection when replacing a broken connection, or pool shutdown) and the underlying Connection.close() throws SQLException because the socket is already broken, the DB closed it server-side, or a network drop occurred.","commonSituations":"Long-lived dSQL (Dameng/DWS ddsql) connections killed by firewall idle timeouts; database restart while SeaTunnel workers hold pooled connections; network partitions in k8s/VM environments; replacing a failed connection during job recovery.","solutions":["Verify network stability between SeaTunnel workers and the dSQL server; check firewall/LB idle timeout settings and raise them or enable TCP keepalive on the JDBC URL","Confirm the database did not kill the session (check server-side session/kill logs, max_idle_time settings)","Reduce connection idle time in the pool or enable validation/validationQuery so dead connections are detected before reuse","If the warning is frequent but jobs succeed, it is benign cleanup noise; investigate only when accompanied by connection failures in the job"],"exampleFix":"// before: jdbc url without keepalive\ndm://host:5236?schema=xxx\n// after: add socket timeout / keepalive options appropriate for the ddsql driver\ndm://host:5236?schema=xxx&socketTimeout=300000&keepAlive=true","handlingStrategy":"retry","validationCode":"// check connectivity before/at job start\ntry (Connection c = DriverManager.getConnection(url, user, pass)) {\n    // if this fails, fix network/credentials before submitting the job\n}","typeGuard":null,"tryCatchPattern":"// wrap pool/reconnect operations and retry on SQLException\ntry {\n    closeConnection();\n} catch (SQLException e) {\n    log.warn(\"JDBC connection close failed, discarding connection\", e);\n    // proceed: connection is already removed from the pool\n}","preventionTips":["Raise firewall/LB idle timeouts or enable TCP keepalive for long-running jobs","Use JDBC connection validation so dead connections are replaced proactively","Monitor DB server logs for killed sessions","Treat isolated close warnings as benign; investigate only alongside job connection failures"],"tags":["jdbc","connection-pool","dameng","ddsql","network"],"backgroundTag":"broken-pipe","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"}