Skip to content

Commit

Permalink
Merge 50a916e into 48df4f4
Browse files Browse the repository at this point in the history
  • Loading branch information
jimfulton committed Feb 8, 2017
2 parents 48df4f4 + 50a916e commit 9567b1b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
10 changes: 9 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions relstorage/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions relstorage/tests/reltestbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 9567b1b

Please sign in to comment.