Skip to content
Permalink
Browse files

Implemented the storage ``afterCompletion`` method, which allows

RelStorage storages to be notified of transaction endings for
transactions that don't call the two-phase commit API.  This allows
resources to be used more efficiently because it prevents RDBMS
transactions from being held open.

Fixes: #147

(At least for ZODB 5.2.)
  • Loading branch information
jimfulton committed Feb 8, 2017
1 parent 48df4f4 commit 50a916e68503f767499977ebaba974ecbeb61ce7
Showing with 24 additions and 1 deletion.
  1. +9 −1 CHANGES.rst
  2. +3 −0 relstorage/storage.py
  3. +12 −0 relstorage/tests/reltestbase.py
@@ -6,7 +6,15 @@
2.1a2 (unreleased)
==================

- Nothing changed yet.
- Implemented the storage ``afterCompletion`` method, which allows
RelStorage storages to be notified of transaction endings for
transactions that don't call the two-phase commit API. This allows
resources to be used more efficiently because it prevents RDBMS
transactions from being held open.

Fixes: https://github.com/zodb/relstorage/issues/147

(At least for ZODB 5.2.)


2.1a1 (2017-02-01)
@@ -1073,6 +1073,9 @@ def _abort(self):
if self.blobhelper is not None:
self.blobhelper.abort()

def afterCompletion(self):
self._rollback_load_connection()

def lastTransaction(self):
with self._lock:
if self._ltid == z64 and self._prev_polled_tid is None:
@@ -847,6 +847,18 @@ def updater():
finally:
db.close()

def checkAfterCompletion(self):
# The after completion method, which can only be called
# outside of 2-phase commit is otherise equivalent to calling
# tpc_abort.
self._storage = self.make_storage(revert_when_stale=False)
import mock
with mock.patch.object(
self._storage, '_rollback_load_connection') as rb:
self._storage.afterCompletion()
rb.assert_called_with()


from .test_zodbconvert import FSZODBConvertTests

class AbstractRSZodbConvertTests(StorageCreatingMixin,

0 comments on commit 50a916e

Please sign in to comment.
You can’t perform that action at this time.