Commit 5da33a35 authored by Kirill Smelkov's avatar Kirill Smelkov

ERP5Type/patches/ZODBConnection: Don't duplicate code from ZODB.Connection.newTransaction

Commit c663257f (Commit fix done by Julien and Leonardo) added network
barrier into ZODB.Connection.newTransaction to fix issues when
activity node A1 was woken up by message from another activity node A2
through SQL, but A1's ZODB view was not yet updated with changes
committed by A2.

That fix prepended `ping` call before original newTransaction actions,
but instead of tailing to original ZODB newTransaction after the ping,
it copied newTransaction code from ZODB.

Today this can cause the following problems:

1) the code that was copied is valid only for ZODB3 and ZODB4, but is not
   valid for ZODB5 as that place was changed by upstream:

   https://github.com/zopefoundation/ZODB/blob/5.5.1-56-gbb9bf5393/src/ZODB/Connection.py#L734-L742

2) wendelin.core 2 relies on patching ZODB.Connection.newTransaction
   further to install "Connection.onResyncCallback" functionality to
   keep ZODB and WCFS connections in sync:

   https://lab.nexedi.com/kirr/wendelin.core/blob/25c3184d/lib/zodb.py#L264-291

   So if ERP5Type.patches is imported after wendelin.lib.zodb, the
   functionality installed by wendelin.core will be lost.

-> Fix both issues by avoiding code duplication and just tailing to
original ZODB newTransaction after the ping.

/cc @seb, @jm, @vpelletier, @romain
parent 7a0d379e
......@@ -35,9 +35,10 @@ if 1: # keep indentation. Also good for quick disabling.
lambda: None)
ping()
def newTransaction(self, *ignored):
newTransaction_orig = Connection.newTransaction
def newTransaction(self, *argv):
self.ping()
self._storage_sync()
newTransaction_orig(self, *argv)
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