Skip to content

Commit 334a93c

Browse files
committed
Fix communication failures with aws-secretsmanager-jdbc
Using aws-secretsmanager-jdbc with HikariCP triggers sporadic communication link failures with MySQL. aws-secretsmanager-jdbc library provides JDBC drivers to retrieve DB credentials, host and password from the Amazon Secrets Manager. See: - https://docs.aws.amazon.com/secretsmanager/latest/userguide/retrieving-secrets_jdbc.html - https://github.com/aws/aws-secretsmanager-jdbc By specifying the secret id as a JDBC an URL, and com.amazonaws.secretsmanager.sql.AWSSecretsManagerMySQLDriver as JDBC driver, HikariCP can connect to the MySQL endpoint. But in this stituation, communication link failures occur: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure The last packet successfully received from the server was 5,006 milliseconds ago. The last packet sent successfully to the server was 5,007 milliseconds ago. These failures are due a MySQL bug: http://bugs.mysql.com/bug.php?id=75615 which is bypassed by HikariCP when the MySQL driver is used. See: - #236 - 8af2bc5 (Fix #236 via workaround for MySQL issue http://bugs.mysql.com/bug.php?id=75615, 2015-01-24) This commit applies the same hack for AWSSecretsManagerMySQLDriver.
1 parent a9147ee commit 334a93c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/main/java/com/zaxxer/hikari/pool/PoolBase.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ else if (dataSourceJNDI != null && ds == null) {
336336

337337
if (ds != null) {
338338
setLoginTimeout(ds);
339-
createNetworkTimeoutExecutor(ds, dsClassName, jdbcUrl);
339+
createNetworkTimeoutExecutor(ds, dsClassName, jdbcUrl, driverClassName);
340340
}
341341

342342
this.dataSource = ds;
@@ -589,12 +589,13 @@ private void executeSql(final Connection connection, final String sql, final boo
589589
}
590590
}
591591

592-
private void createNetworkTimeoutExecutor(final DataSource dataSource, final String dsClassName, final String jdbcUrl)
592+
private void createNetworkTimeoutExecutor(final DataSource dataSource, final String dsClassName, final String jdbcUrl, final String driverClassName)
593593
{
594594
// Temporary hack for MySQL issue: http://bugs.mysql.com/bug.php?id=75615
595595
if ((dsClassName != null && dsClassName.contains("Mysql")) ||
596596
(jdbcUrl != null && jdbcUrl.contains("mysql")) ||
597-
(dataSource != null && dataSource.getClass().getName().contains("Mysql"))) {
597+
(dataSource != null && dataSource.getClass().getName().contains("Mysql")) ||
598+
"com.amazonaws.secretsmanager.sql.AWSSecretsManagerMySQLDriver".equals(driverClassName)) {
598599
netTimeoutExecutor = new SynchronousExecutor();
599600
}
600601
else {

0 commit comments

Comments
 (0)