Commit fix done by Julien and Leonardo
Activities could read from the ZODB an state older than the one that caused the activity to be created, if: 1.Zope client node (node A) processing an activity message is different than the one that created the activity (node B), 2.The object cache for node A contains objects concerning the activity message (or its container) 3.The node A hasn't yet received the invalidation message from the ZEO server, for instance, if its still on the network layer (kernel buffers, routers in between, etc...) The simplest fix for this issue is sending a synchronous message to the ZEO server before the beginning of a transaction. This message will act like a “network barrier”, making sure that any invalidation messages sent before that point from the ZEO server are already received, and the transaction can begin with an “updated enough” state. Additional note from Yoshinori : This patch must be proposed to zope developpers as soon as possible and see with them if this way is the best. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39710 20353a03-c40f-0410-a6d1-a30d3c3de9de
Showing
############################################################################## | |||
# | |||
# Copyright (c) 2010 Nexedi SA and Contributors. | |||
# | |||
# This software is subject to the provisions of the Zope Public License, | |||
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. | |||
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED | |||
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |||
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS | |||
# FOR A PARTICULAR PURPOSE | |||
# | |||
############################################################################## | |||
# 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. | |||
from ZODB.Connection import Connection | |||
if 1: # keep indentation. Also good for quick disabling. | |||
def ping(self): | |||
# Use a synchronous call to make sure we have received all invalidation | |||
# methods that could be stuck in the wire so MVCC behaves correctly. | |||
# XXX Use a proper ping method exported by ClientStorage instead of | |||
# this hack | |||
ping = getattr(getattr(self._storage, '_server', None), | |||
'getAuthProtocol', | |||
lambda: None) | |||
ping() | |||
def newTransaction(self, *ignored): | |||
self.ping() | |||
self._storage_sync() | |||
|
|||
Connection.ping = ping | |||
Connection.newTransaction = newTransaction | |||
-
mentioned in merge request !1095 (closed)
-
mentioned in commit kirr/ZEO@d4805a0f
-
mentioned in merge request wendelin.core!13 (closed)