[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
This commit is contained in:
parent
2a59ce92e3
commit
ad06d1ba56
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue