Commit 77c7369c authored by Vincent Pelletier's avatar Vincent Pelletier

Trigger barrier upon first _load call in transaction.

Otherwise, it might not be called (it connector is not present at
transaction manager's "begin" call time).

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2406 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 795082b4
......@@ -192,19 +192,3 @@ class Storage(BaseStorage.BaseStorage,
def close(self):
self.app.close()
def invalidationBarrier(self):
self.app.invalidationBarrier()
# Monkey-patch ZODB.Connection to fetch all invalidations before starting a
# transaction.
from ZODB.Connection import Connection
# XXX: a better detection should be done if this patch enters ZODB
INVALIDATION_MARKER = '__INVALIDATION_BARRIER_PATCH_IS_HERE__'
if not hasattr(Connection, INVALIDATION_MARKER):
orig_newTransaction = Connection.newTransaction
def newTransaction(self, *ignored):
getattr(self._storage, 'invalidationBarrier', lambda: None)()
orig_newTransaction(self, *ignored)
Connection.newTransaction = newTransaction
setattr(Connection, INVALIDATION_MARKER, True)
......@@ -115,6 +115,7 @@ class ThreadContext(object):
'asked_object': 0,
'undo_object_tid_dict': {},
'involved_nodes': set(),
'barrier_done': False,
}
......@@ -479,6 +480,13 @@ class Application(object):
"""
# TODO:
# - rename parameters (here and in handlers & packet definitions)
# Once per transaction, upon first load, trigger a barrier so we
# handle all pending invalidations, so the snapshot of the database is
# as up-to-date as possible.
if not self.local_var.barrier_done:
self.invalidationBarrier()
self.local_var.barrier_done = True
cell_list = self._getCellListForOID(oid, readable=True)
if len(cell_list) == 0:
# No cells available, so why are we running ?
......
......@@ -227,6 +227,7 @@ class ClientApplicationTests(NeoUnitTestBase):
def test_load(self):
app = self.getApp()
app.local_var.barrier_done = True
mq = app.mq_cache
oid = self.makeOID()
tid1 = self.makeTID(1)
......@@ -291,6 +292,7 @@ class ClientApplicationTests(NeoUnitTestBase):
def test_loadSerial(self):
app = self.getApp()
app.local_var.barrier_done = True
mq = app.mq_cache
oid = self.makeOID()
tid1 = self.makeTID(1)
......@@ -330,6 +332,7 @@ class ClientApplicationTests(NeoUnitTestBase):
def test_loadBefore(self):
app = self.getApp()
app.local_var.barrier_done = True
mq = app.mq_cache
oid = self.makeOID()
tid1 = self.makeTID(1)
......
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