]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Added pool logging for "rollback-on-return" and the less used
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 9 Jun 2013 20:16:53 +0000 (16:16 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 9 Jun 2013 20:16:53 +0000 (16:16 -0400)
"commit-on-return".  This is enabled with the rest of pool
"debug" logging.
[ticket:2752]

doc/build/changelog/changelog_09.rst
lib/sqlalchemy/pool.py

index 4d344a13d5d766ffde987190e519742a872798e7..f1d0bcc926558ea4a1f3dd96aa2ad4146efbe718 100644 (file)
@@ -6,6 +6,14 @@
 .. changelog::
     :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
index 0470e9e485249ea903c93d4cbe58b5ddcd9c5a05..ade1e90ceb9c901e091e119497d82dae2b57d55c 100644 (file)
@@ -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