summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/build/changelog/changelog_09.rst8
-rw-r--r--lib/sqlalchemy/pool.py19
2 files changed, 21 insertions, 6 deletions
diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst
index 4d344a13d..f1d0bcc92 100644
--- a/doc/build/changelog/changelog_09.rst
+++ b/doc/build/changelog/changelog_09.rst
@@ -7,6 +7,14 @@
:version: 0.9.0
.. change::
+ :tags: feature, pool
+ :tickets: 2752
+
+ Added pool logging for "rollback-on-return" and the less used
+ "commit-on-return". This is enabled with the rest of pool
+ "debug" logging.
+
+ .. change::
:tags: bug, mysql
:tickets: 2715
diff --git a/lib/sqlalchemy/pool.py b/lib/sqlalchemy/pool.py
index 0470e9e48..ade1e90ce 100644
--- a/lib/sqlalchemy/pool.py
+++ b/lib/sqlalchemy/pool.py
@@ -193,8 +193,8 @@ class Pool(log.Identified):
except (SystemExit, KeyboardInterrupt):
raise
except:
- self.logger.debug("Exception closing connection %r",
- connection)
+ self.logger.error("Exception closing connection %r",
+ connection, exc_info=True)
@util.deprecated(
2.7, "Pool.add_listener is deprecated. Use event.listen()")
@@ -381,12 +381,22 @@ def _finalize_fairy(connection, connection_record, pool, ref, echo):
return
if connection is not None:
+ if connection_record and echo:
+ pool.logger.debug("Connection %r being returned to pool",
+ connection)
+
try:
if pool.dispatch.reset:
pool.dispatch.reset(connection, connection_record)
if pool._reset_on_return is reset_rollback:
+ if echo:
+ pool.logger.debug("Connection %s rollback-on-return",
+ connection)
pool._dialect.do_rollback(connection)
elif pool._reset_on_return is reset_commit:
+ if echo:
+ pool.logger.debug("Conneciton %s commit-on-return",
+ connection)
pool._dialect.do_commit(connection)
# Immediately close detached instances
if connection_record is None:
@@ -399,9 +409,6 @@ def _finalize_fairy(connection, connection_record, pool, ref, echo):
if connection_record is not None:
connection_record.fairy = None
- if echo:
- pool.logger.debug("Connection %r being returned to pool",
- connection)
if connection_record.finalize_callback:
connection_record.finalize_callback(connection)
del connection_record.finalize_callback
@@ -436,7 +443,7 @@ class _ConnectionFairy(object):
self._connection_record = None
raise
if self._echo:
- self._pool.logger.debug("Connection %r checked out from pool" %
+ self._pool.logger.debug("Connection %r checked out from pool",
self.connection)
@property