Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Patch idle connection #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jinpeng007
Copy link

Hey BoneCP Folks,

Here is a patch based on the 0.8.0 release to address the connection pool size overflow issues.

We've identified two problems while using BoneCP in our product:

  1. The connectionCreated counter can go into negative value during network failures between the application nodes and the database servers. Once the value is negative, the BoneCP PoolWatchThread always try to keep 2*maxConnectionsPerPartition connections for each partition.
  2. In the ConnectionTesterThread, when the connection's idle time > the idleMaxAgeInSeconds, the connection is killed, but immediately a new connection is created in the pool. Due to this logic, once the connection pool gets to the full size maxConnectionsPerPartition, it will stay full forever.

bonecpconnectionoverflow

We use BoneCP in a distributed environment, the number of connections to database servers from each application node can significantly impact the scalability and robustness of the system. We want to keep the number connections from each node as the minimum all the time: only increase the pool size on demand; after peak time usage, let the idle timeout logic kick in to shrink the pool size to minimum.

The patch provided two fixes:

  1. Make sure connectionCreated >= 0.
  2. Let idle connections die off the connection pool after idleMaxAgeInSeconds, therefore allow the pool size to shrink.

Also make sure the connectionCreated counter cannot be negative value
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants