[server/session] make commit/rollback obey ensure_cnx_set
Inside the ensure_cnx_set context manager, commit and rollback aren't
allowed to dispose of the cnxset.
--- a/server/session.py Wed Apr 09 14:05:54 2014 +0200
+++ b/server/session.py Tue Apr 22 14:43:11 2014 +0200
@@ -531,6 +531,7 @@
def __exit__(self, exctype=None, excvalue=None, tb=None):
assert self._open # actually already open
+ assert self._cnxset_count == 0
self._free_cnxset(ignoremode=True)
self.clear()
self._open = False
@@ -619,6 +620,7 @@
# or rollback
cnxset = self.cnxset
if cnxset is not None and (ignoremode or self.mode == 'read'):
+ assert self._cnxset_count == 0
try:
self.cnxset = None
finally:
@@ -1027,6 +1029,9 @@
warn('[3.13] use free_cnxset argument instead for reset_pool',
DeprecationWarning, stacklevel=2)
free_cnxset = reset_pool
+ if self._cnxset_count != 0:
+ # we are inside ensure_cnx_set, don't lose it
+ free_cnxset = False
cnxset = self.cnxset
if cnxset is None:
self.clear()
@@ -1064,6 +1069,9 @@
self._session_timestamp.touch()
self.debug('commit transaction %s done (no db activity)', self.connectionid)
return
+ if self._cnxset_count != 0:
+ # we are inside ensure_cnx_set, don't lose it
+ free_cnxset = False
cstate = self.commit_state
if cstate == 'uncommitable':
raise QueryError('transaction must be rolled back')