Skip to content

Conversation

@rPraml
Copy link
Collaborator

@rPraml rPraml commented Feb 27, 2025

We discovered an issue, when the connection pool is full, the heartbeat will reset the pool, although this is not necessary.

How to reproduce:

  • create a pool (e.g. maxSize = 1)
  • start as many threads as maxSize that will hold the connection longer than heartbeatfreq + waitTimeoutMillis
  • heartbeat will not get a connection and thinks, datasource is down, which is not true.

This PR changes, how heartbeat detects, if connection is valid.

  • If the pool is full, a ConnectionPoolExhaustedException extends SQLException is thrown
  • If the hearbeat tries to validate the connection and gets a ConnectionPoolExhaustedException it will be ignored multiple times.

We ignore this exception heartbeatMaxPoolExhaustedCount times. Normally this is not needed, but if there are really leaking connections (e.g. forgot to close) we perform a reset, if this happened repeatetly

rPraml added a commit to FOCONIS/ebean-datasource that referenced this pull request Feb 27, 2025
@rbygrave rbygrave added this to the 9.3 milestone Feb 27, 2025
@rbygrave rbygrave merged commit 7ef074b into ebean-orm:master Feb 27, 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.

2 participants