Commit c663257f authored by Sebastien Robin's avatar Sebastien Robin

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
parent 3b75430c
...@@ -322,6 +322,7 @@ class SQLBase: ...@@ -322,6 +322,7 @@ class SQLBase:
# So all connectors must be committed now that we have selected # So all connectors must be committed now that we have selected
# everything needed from MySQL to get a fresh view of ZODB objects. # everything needed from MySQL to get a fresh view of ZODB objects.
transaction.commit() transaction.commit()
transaction.begin()
tv = getTransactionalVariable() tv = getTransactionalVariable()
tv['activity_runtime_environment'] = activity_runtime_environment tv['activity_runtime_environment'] = activity_runtime_environment
# Try to invoke # Try to invoke
......
...@@ -62,6 +62,7 @@ from Products.ERP5Type.patches import make_hidden_input ...@@ -62,6 +62,7 @@ from Products.ERP5Type.patches import make_hidden_input
from Products.ERP5Type.patches import ClientStorage from Products.ERP5Type.patches import ClientStorage
from Products.ERP5Type.patches import DemoStorage from Products.ERP5Type.patches import DemoStorage
from Products.ERP5Type.patches import unicodeconflictresolver from Products.ERP5Type.patches import unicodeconflictresolver
from Products.ERP5Type.patches import ZODBConnection
# BACK: Forward Compatibility with Zope 2.12 or CMF 2.2. Remove when we've # BACK: Forward Compatibility with Zope 2.12 or CMF 2.2. Remove when we've
# dropped support for older versions. # dropped support for older versions.
from Products.ERP5Type.patches import TransactionAddBeforeCommitHook from Products.ERP5Type.patches import TransactionAddBeforeCommitHook
......
##############################################################################
#
# 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()
Please register or sign in to reply
Connection.ping = ping
Connection.newTransaction = newTransaction
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