Log an exception when reconnect-to-disconnected occurs

The scenario where an existing database connection that's
present in the pool is found to be not connected to the
database should normally not be occurring; the idle_timeout
setting (aka pool_recycle) should be less than the effective "idle timeout"
set up on the server and/or HAProxy such that a stale
connection in the pool should already have been recycled.

As a system with a mis-configured idle_timeout can experience
latency due to this error hook, it should be reported that
this is an avoidable situation which is occurring. Right
now there's no easy way to see if a performance test is
spending lots of time hitting this condition or not.

Change-Id: I3e9613cbb982c727762247201c5c4972e21da725
This commit is contained in:
Mike Bayer 2017-07-17 15:03:20 -04:00
parent 3971a6f94d
commit 83563e0acc
1 changed files with 2 additions and 0 deletions

View File

@ -77,6 +77,8 @@ def _connect_ping_listener(connection, branch):
# "invalid", but the pool should be ready to return
# new connections assuming they are good now.
# run the select again to re-validate the Connection.
LOG.exception(
'Database connection was found disconnected; reconnecting')
connection.scalar(select([1]))
finally:
connection.should_close_with_result = save_should_close_with_result