[server/session] add missing rollback when freeing a db connection
authorJulien Cristau <julien.cristau@logilab.fr>
Mon, 28 Apr 2014 12:54:14 +0200
changeset 9707 4a23058e4d9f
parent 9706 f24c30a19898
child 9708 b36bc18f6ef7
[server/session] add missing rollback when freeing a db connection When we let go of a cnxset and give it back to the pool, we need to make sure it's not in the middle of a transaction. We got bitten by a migration where the connection used by admin's repo.connect was not rolled back before attempting the migration, causing a deadlock because it had a lock on a table. This could potentially also be an issue for e.g. hooks or looping tasks that didn't explicitly rollback before calling free_cnxset or moving out of a ensure_cnx_set block.
server/session.py
--- a/server/session.py	Thu Apr 24 17:52:20 2014 +0200
+++ b/server/session.py	Mon Apr 28 12:54:14 2014 +0200
@@ -593,6 +593,7 @@
             if new_cnxset is old_cnxset:
                 return #nothing to do
             if old_cnxset is not None:
+                old_cnxset.rollback()
                 self._cnxset = None
                 self.ctx_count -= 1
                 self._cnxset_tracker.forget(self.connectionid, old_cnxset)