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

When creating physical connections, catch throwable instead of exception #2300

Conversation

cgravatt
Copy link
Contributor

@cgravatt cgravatt commented Mar 18, 2025

Although rare, JDBC drivers can and do throw java.lang.Error instead of java.lang.Exception under certain conditions. If this occurs, the Error is swallowed since it is not currently caught and it occurs on a separate thread where the result is never checked.

If the driver continues to throw Error, the backoff logic is bypassed, the connection creation counter spikes and eventually the pool drains of all connections.

See example

Graph of connection creation counter
image

Graph of connections for the pool
image

The trigger was a networking event. At this time, we don't know with absolute certainty that the driver was generating an Error. However, after reviewing the code, I could not determine another explanation. The backoff logic clearly was not being hit as the counter would not increase and stay at the rate. We put out a patched version of Hikari similar to the changes in this PR with hopes of confirming that is what is happening and collecting the actual error being thrown, but we are waiting for the situation to occur again.

In this case we are using oracle's jdbc driver, and we have seen it throw a java.lang.Error before in other situations.

If this change is of interest and you want an explicit test for this, I'm happy to do that, but I may need a little direction on preferences here.

…of java.lang.Exception under certain conditions. If this occurs, the Error is swallowed since it is not currently caught and it occurs on a separate thread where the result is never checked. If the driver continues to throw Error, this bypasses the backoff logic, spikes the connection creation counter. Eventually the pool drains of connections with no trace of the real reason in the logs
@brettwooldridge brettwooldridge merged commit 8257a99 into brettwooldridge:dev Mar 21, 2025
1 check passed
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.

None yet

2 participants