Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix communication failures with aws-secretsmanager-jdbc #1932

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

gontard
Copy link

@gontard gontard commented May 2, 2022

See commit message.

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:

 - brettwooldridge#236
 - 8af2bc5 (Fix brettwooldridge#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.
@gontard gontard marked this pull request as ready for review May 2, 2022 12:29
{
// Temporary hack for MySQL issue: http://bugs.mysql.com/bug.php?id=75615
if ((dsClassName != null && dsClassName.contains("Mysql")) ||
(jdbcUrl != null && jdbcUrl.contains("mysql")) ||
(dataSource != null && dataSource.getClass().getName().contains("Mysql"))) {
(dataSource != null && dataSource.getClass().getName().contains("Mysql")) ||
"com.amazonaws.secretsmanager.sql.AWSSecretsManagerMySQLDriver".equals(driverClassName)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In your case, what is the dataSource classname? Does it contain the name "MySQL", if so the existing contains("Mysql") maybe should just be changed to a case insensitive check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants