From ad06d1ba565c61a59403087a3b0751267ae5d76c Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Tue, 13 Sep 2011 16:34:44 +0200 Subject: [PATCH] [FIX] This complements commit 3511, revision-id: odo@openerp.com-20110714105552-9tgofrjtdgjmgc4b. Each OpenERP cursor is mapped to a single psycopg2 connexion. When a cursor is closed, the connexion is pushed back to a pool and reused later. Now that the 'snapshot isolation' level is used, the fact we didn't properly commit/rollback a transaction appears: some 'concurrent' update showed up. The fix is simple: whenever a cursor is closed, we rollback any pending operation (which is the expected behavior). (Furthermore, the connexion is explicitely closed when the connexion is pushed back but not kept in the pool.) bzr revid: vmt@openerp.com-20110913143444-s49r7r2h6m00p5s3 --- openerp/sql_db.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openerp/sql_db.py b/openerp/sql_db.py index f4a899c8db2..79606b9101c 100644 --- a/openerp/sql_db.py +++ b/openerp/sql_db.py @@ -294,6 +294,9 @@ class Cursor(object): del self._obj self.__closed = True + # Clean the underlying connection. + self._cnx.rollback() + if leak: self._cnx.leaked = True else: @@ -430,6 +433,7 @@ class ConnectionPool(object): self._debug('Put connection to %r in pool', cnx.dsn) else: self._debug('Forgot connection to %r', cnx.dsn) + cnx.close() break else: raise PoolError('This connection does not below to the pool')