Skip to content

Conversation

@HexyWitch
Copy link
Contributor

I encountered an issue where after some time the server would start timing out trying to connect to the mysql server. I'm fairly sure I've narrowed it down to the ongoing count in Pool not always being decremented when connections are dropped or disconnected. As soon as it reaches the PoolConstraints max, and the idle pool has been exhausted, the Pool stops creating any new connections and locks up forever.

I don't have a minimal reproduction case, so instead have this long description of why I think this change is correct:

Ongoing count is incremented when:

  1. A new connection has been created and initiated (sets the inner pool)
  2. A connection is popped from the idle connections pool

With my changes the count is now decremented when:

  1. A connection is dropped or disconnected (if it has an inner pool)
  2. A connection is pushed to the idle connections pool

I believe this behavior is correct as long as:

  • Conn::pool is always set when a connection is taken from the pool
  • Conn::pool is never reset while the connection is ongoing
  • Conn::pool is always immediately reset when the connection is disconnected

It seems stable in local testing under high stress, and in production.

@blackbeam
Copy link
Owner

Thanks! I'll look into it.

@blackbeam blackbeam merged commit d29b261 into blackbeam:master Apr 7, 2019
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