diff --git a/relstorage/__init__.py b/relstorage/__init__.py index 1805b0af..0af8608c 100644 --- a/relstorage/__init__.py +++ b/relstorage/__init__.py @@ -34,30 +34,12 @@ def patch_zodb_sync(): """Patch Connection.sync() and afterCompletion() to pass the 'force' flag. """ - def _storage_sync(self, *ignored, **kw): - if hasattr(self, '_readCurrent'): - self._readCurrent.clear() - sync = getattr(self._storage, 'sync', 0) - if sync: - # By default, do not force the sync, allowing RelStorage - # to ignore sync requests for a while. - force = kw.get('force', False) - try: - sync(force=force) - except TypeError: - # The 'force' parameter is not accepted. - sync() - self._flush_invalidations() - def sync(self): """Manually update the view on the database.""" + self._storage.sync(force=True) self.transaction_manager.abort() - self._storage_sync(force=True) from ZODB.Connection import Connection - Connection._storage_sync = _storage_sync - Connection.afterCompletion = _storage_sync - Connection.newTransaction = _storage_sync Connection.sync = sync patch_zodb_sync() diff --git a/relstorage/storage.py b/relstorage/storage.py index 1072b3e1..3f78a1df 100644 --- a/relstorage/storage.py +++ b/relstorage/storage.py @@ -957,7 +957,7 @@ def _abort(self): def lastTransaction(self): self._lock_acquire() try: - return self._ltid + return max(self._ltid, p64(self._prev_polled_tid or 0)) finally: self._lock_release() @@ -1203,7 +1203,7 @@ def _pack_finished(self): def iterator(self, start=None, stop=None): return TransactionIterator(self._adapter, start, stop) - def sync(self, force=True): + def sync(self, force=False): """Updates to a current view of the database. This is implemented by rolling back the relational database diff --git a/relstorage/tests/blob/testblob.py b/relstorage/tests/blob/testblob.py index 063f1c28..56e612c1 100644 --- a/relstorage/tests/blob/testblob.py +++ b/relstorage/tests/blob/testblob.py @@ -14,7 +14,7 @@ from ZODB.blob import Blob from ZODB.DB import DB -from zope.testing import doctest +import doctest import atexit import collections @@ -437,7 +437,11 @@ def loadblob_tmpstore(): ... tmpstore = TmpStore(blob_storage) ... except TypeError: ... # ZODB 3.8 - ... tmpstore = TmpStore('', blob_storage) + ... try: + ... tmpstore = TmpStore('', blob_storage) + ... except AttributeError: + ... # ZODB >=5 + ... tmpstore = TmpStore(blob_storage, connection._txn_time) We can access the blob correctly: diff --git a/relstorage/tests/reltestbase.py b/relstorage/tests/reltestbase.py index 55166c8b..e0d08848 100644 --- a/relstorage/tests/reltestbase.py +++ b/relstorage/tests/reltestbase.py @@ -410,7 +410,12 @@ def checkPollInterval(self, shared_cache=True): self.assertFalse(c2._storage.need_poll()) tm2.commit() r2 = c2.root() - self.assertEqual(r2['alpha'], 1) + try: + self.assertEqual(r2['alpha'], 1) + except AssertionError: + if hasattr(c1, '_flush_invalidations'): + # Only fail with ZODB <5 + raise # expire the poll timer and verify c2 sees the change c2._storage._poll_at -= 3601