Commit 95a75303 authored by Julien Muchembled's avatar Julien Muchembled

Fix some monkey-patches to make them compatible with ZODB5

See also https://github.com/zopefoundation/ZEO/pull/63
     and nexedi/erp5!1095

No error in testCMFActivity and testConflictResolution.
For the only error in testInvalidationBug, see comment.

But this commit is not enough for ZODB5. The only known issue so far
is the use of newer pickle protocol, which breaks export of ZODB data
and requires non-trivial changes in our XMLExportImport/ppml code.
So for the moment, many failures in testBusinessTempate.
parent 4cb27dec
...@@ -90,6 +90,9 @@ class TestInvalidationBug(ERP5TypeTestCase): ...@@ -90,6 +90,9 @@ class TestInvalidationBug(ERP5TypeTestCase):
self.assertEqual(result_list[-2], None) # ZODB self.assertEqual(result_list[-2], None) # ZODB
self.assertEqual(result_list[-1], [1,1]) # activity tables last self.assertEqual(result_list[-1], [1,1]) # activity tables last
# TODO: - skip this test for ZEO>=5 because it's covered upstream
# (and later remove it)
# - in slapos.git, enable server_sync in zope.conf
def testLateInvalidationFromZEO(self): def testLateInvalidationFromZEO(self):
### Check unit test is run properly ### Check unit test is run properly
from ZEO.ClientStorage import ClientStorage from ZEO.ClientStorage import ClientStorage
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
############################################################################## ##############################################################################
from ZODB import DemoStorage as _DemoStorage from ZODB import DemoStorage as _DemoStorage
from ZODB.ConflictResolution import ConflictResolvingStorage, ResolvedSerial from ZODB.ConflictResolution import ConflictResolvingStorage
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
class DemoStorage(_DemoStorage.DemoStorage, ConflictResolvingStorage): class DemoStorage(_DemoStorage.DemoStorage, ConflictResolvingStorage):
...@@ -33,4 +33,5 @@ class DemoStorage(_DemoStorage.DemoStorage, ConflictResolvingStorage): ...@@ -33,4 +33,5 @@ class DemoStorage(_DemoStorage.DemoStorage, ConflictResolvingStorage):
if not issubclass(_DemoStorage.DemoStorage, ConflictResolvingStorage): if not issubclass(_DemoStorage.DemoStorage, ConflictResolvingStorage):
# BBB: ZODB < 4.3 # BBB: ZODB < 4.3
from ZODB.ConflictResolution import ResolvedSerial
_DemoStorage.DemoStorage = DemoStorage _DemoStorage.DemoStorage = DemoStorage
...@@ -107,9 +107,7 @@ def exportXML(jar, oid, file=None): ...@@ -107,9 +107,7 @@ def exportXML(jar, oid, file=None):
def getReorderedPickle(oid): def getReorderedPickle(oid):
p = pickle_dict[oid] p = pickle_dict[oid]
if p is None: if p is None:
# Versions are ignored, but some 'load()' implementations require them p = load(oid)[0]
# FIXME: remove "''" when TmpStore.load() on ZODB stops asking for it.
p = load(oid, '')[0]
p = reorderPickle(jar, p)[1] p = reorderPickle(jar, p)[1]
if len(p) < max_cache[0]: if len(p) < max_cache[0]:
max_cache[0] -= len(p) max_cache[0] -= len(p)
......
...@@ -11,36 +11,29 @@ ...@@ -11,36 +11,29 @@
# #
############################################################################## ##############################################################################
# override ZODB.Connection.newTransaction() to do a synchronous call before
# flushing all invalidations, this will serve as a "network barrier" that
# will force Connection to wait for all invalidations sent from other parallel
# transactions so that, for instance, activity processing can see a recent
# enough state of the ZODB.
import time import time
from Products.ERP5Type.Timeout import TimeoutReachedError, getDeadline from Products.ERP5Type.Timeout import TimeoutReachedError, getDeadline
from ZODB.Connection import Connection from ZODB.Connection import Connection
FORCE_STORAGE_SYNC_ON_CONNECTION_OPENING = False FORCE_STORAGE_SYNC_ON_CONNECTION_OPENING = False
if 1: # keep indentation. Also good for quick disabling. if 1: # for quick disabling.
def ping(self): if hasattr(Connection, '_storage_sync'): # ZODB<5
# Use a synchronous call to make sure we have received all invalidation # BBB: For ZEO<5, use a synchronous call to make sure we have received
# methods that could be stuck in the wire so MVCC behaves correctly. # all invalidation methods that could be stuck in the wire so MVCC
# XXX Use a proper ping method exported by ClientStorage instead of # behaves correctly. This can be seen as a "network barrier",
# this hack # so that, for instance, activity processing can see a recent
ping = getattr(getattr(self._storage, '_server', None), # enough state of the ZODB.
'getAuthProtocol', # ZEO5 has an option and NEO does it by default.
lambda: None)
ping()
def newTransaction(self, *ignored): def newTransaction(self, *ignored):
self.ping() zeo = getattr(self._storage, '_server', None)
self._storage_sync() if zeo is not None:
zeo.getAuthProtocol()
self._storage_sync()
Connection.ping = ping Connection.newTransaction = newTransaction
Connection.newTransaction = newTransaction
if FORCE_STORAGE_SYNC_ON_CONNECTION_OPENING: if FORCE_STORAGE_SYNC_ON_CONNECTION_OPENING:
......
...@@ -168,7 +168,10 @@ else: ...@@ -168,7 +168,10 @@ else:
else: else:
forkNodes() forkNodes()
from ZEO.ClientStorage import ClientStorage from ZEO.ClientStorage import ClientStorage
Storage = ClientStorage(zeo_client) try:
Storage = ClientStorage(zeo_client, server_sync=True)
except TypeError: # BBB: ZEO<5
Storage = ClientStorage(zeo_client)
if node_pid_list is not None: if node_pid_list is not None:
_print("Instance at %r loaded ... " % instance_home) _print("Instance at %r loaded ... " % instance_home)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment