-
Notifications
You must be signed in to change notification settings - Fork 46
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
java.util.ConcurrentModificationException occurring during HikariCP isConnectionAlive()/isConnectionDead() starting with release 2.3.3 #855
Comments
Hi @malacroix, Thanks for reaching out and raising this issue. We'll take a look at this and keep you updated as we investigate. Thank you for your patience! |
I am seeing something similar. I think it might be caused by the efm2 plugin... |
Hi @malacroix Would you be able to provide what versions of Spring Boot and Hikari you are using, as well as any configurations you may be using for them? Thank you |
@aaronchung-bitquill We have many applications that are "micro-services", isolated from each other and each are using different sets of dependency versions (though they are all at AWS Advanced JDBC Wrapper 2.3.3). I can get the different combinations of dependency versions they are using. Though for the configurations, each applications have their own
I will come back soon with a good sample of the various combinations of dependencies for our different applications. |
We are facing a similar issue during our stress tests. we are using AWS Advanced JDBC Driver 2.3.3 with HikariCP v5.0.1 and SpringBoot v3.1.7. Enabling efm (efm2 disabled) does not lead to any problems. |
Oh thanks @canelzio for reporting this! I wanted to test out disabling efm2 as the next step, but with your confirmation, I think its rather clear it pinpoints to an issue in efm2. So, I'll still report the combinations of dependencies for our different applications that are using the AWS Advanced JDBC driver wrapper 2.3.3 and are getting the "java.util.ConcurrentModificationException" exception.
Now, these are combinations of dependencies for applications that do not generate any "java.util.ConcurrentModificationException" exceptions.
At first, I was thinking that there could be some conflict with Spring Boot 2.6.X and higher, but this one case with Spring Boot |
Hi @malacroix @NikolayMetchev @canelzio We have just merged in a fix. Could you kindly check our snapshot build and let us know if the issue still persists? Thank you! |
The issue is in this line of code: The efm2 plugin uses a regular HashMap that is not thread-safe while the efm code uses a ConcurrentLinkedQueue that is thread-safe. Here is the declaration in efm2: And efm: I just filed an AWS support case earlier today with this information as we started getting these exceptions in one of our services under load. |
If this is a blocker for anyone, a workaround would to be use For visibility, this can be done using the Note that if you were previously using the default plugins by not specifying the
|
We already figured it out and are changing the configuration to use I also saw in your code that you are using ConcurrentHashMap - while that will solve the issue, ConcurrentHashMap comes with a performance hit - it will be better to use Caffeine (https://github.com/ben-manes/caffeine/wiki/Benchmarks) since it's much faster and offers very close semantics to Guava's cache or ConcurrentHashMap. |
Hi @aaronchung-bitquill |
@aaronchung-bitquill, I can also confirm that the latest 2.3.4 Snapshot doesn't generate the error anymore. |
@dejandb Thank you for suggesting Caffeine. Those benchmarks look promising. We'll give it a look. @canelzio @malacroix Glad to hear that it is working for you guys and with similar performance. As such, I'll be closing this ticket. However, if you require further assistance, feel free to reopen this issue or create a new one. Thank you! |
Hi @malacroix @NikolayMetchev @canelzio @dejandb I wanted to let you know that the fix is now available on the latest version of the driver. Thank you! |
Describe the bug
After upgrading our AWS Advanced JDBC Driver to
2.3.3
(from2.3.1
) on various Spring Boot applications, we started noticing the following warning in our logs:Looking at HikariCP code, we see the warning being generated from the
isConnectionDead()
(see here) and we can see the method is called when getting a connection from the Connection Pool and it must validate if the connection is still alive or dead (see here)Expected Behavior
The ConcurrentModificationException should not be happening
What plugins are used? What other connection properties were set?
No specific plugins or other AWS specific connection properties configured, so using all defaults.
Current Behavior
We are getting the following error consistently:
This is causing the connection to be identified as dead and thus HikariCP closes the connection and gets another one from its pool.
Reproduction Steps
see above
Possible Solution
N/A
Additional Information/Context
We have multiple environments, some are using AWS Aurora MySQL, some outside and are using play MySQL (or from other provider). And we have many services that have started upgrading to AWS advanced JDBC Driver.
This error doesn't happen when using the MySQL Connector/J driver
com.mysql.cj.jdbc.Driver
directly for non AWS environments. It only happens on environments using AWS Aurora databases and when configuring JDBC Driver tosoftware.amazon.jdbc.Driver
with the JDBC protocol asjdbc:aws-wrapper:mysql:
.It seems the
mysql-connector-j
version being used doesn't really matter. We have noticed the error on services using MySQL Connector8.0.21
,8.0.33
or8.2.0
, but also haven't seen the issue on other services having the same versions.We confirmed that the error seems to be happening from
2.3.3
release. Most of our services have upgraded from2.3.1
directly to2.3.3
when we started seeing those errors, but then, we went back to2.3.1
(where the issue wasn't seen) and upgraded by a single version to2.3.2
and we couldn't see the error. So that seems to confirm the issue is being introduced in2.3.3
and wasn't present in2.3.2
or below.The AWS Advanced JDBC Driver version used
2.3.3
JDK version used
A wide range of JDK docker images (openjdk:11-jdk-slim, openjdk:11.0.5-jre-slim, eclipse-temurin:17-jdk...)
Operating System and version
see JDK version images
The text was updated successfully, but these errors were encountered: