Commit 4a4d2e64 authored by Julien Muchembled's avatar Julien Muchembled

client: optimize by not calling lastTransaction at the end of transactions

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2813 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent d87f899b
......@@ -126,8 +126,10 @@ class Storage(BaseStorage.BaseStorage,
return self.app.tpc_abort(transaction=transaction)
def tpc_finish(self, transaction, f=None):
return self.app.tpc_finish(transaction=transaction,
tid = self.app.tpc_finish(transaction=transaction,
tryToResolveConflict=self.tryToResolveConflict, f=f)
self._snapshot_tid = add64(tid, 1)
return tid
@check_read_only
def store(self, oid, serial, data, version, transaction):
......@@ -209,9 +211,6 @@ class Storage(BaseStorage.BaseStorage,
raise KeyError
def sync(self, force=True):
# XXX: Unfortunately, we're quite slow (lastTransaction) and
# we're also called at the end of each transaction by ZODB
# (see Connection.afterCompletion), probably for no useful reason.
# Increment by one, as we will use this as an excluded upper
# bound (loadBefore).
self._snapshot_tid = add64(self.lastTransaction(), 1)
......
......@@ -51,10 +51,10 @@ if needs_patch:
Connection.tpc_finish = tpc_finish
try:
if Connection._nexedi_fix != 1:
if Connection._nexedi_fix != 2:
raise Exception("A different ZODB fix is already applied")
except AttributeError:
Connection._nexedi_fix = 1
Connection._nexedi_fix = 2
# Whenever an connection is opened (and there's usually an existing one
# in DB pool that can be reused) whereas the transaction is already
......@@ -88,6 +88,16 @@ if needs_patch:
Connection_open = Connection.open
Connection.open = open
# Storage.sync usually implements a "network barrier" (at least
# in NEO, but ZEO should be fixed to do the same), which is quite
# slow so we prefer to not call it where it's not useful.
# I don't know any legitimate use of DB access outside a transaction.
def afterCompletion(self, *ignored):
self._readCurrent.clear()
self._flush_invalidations()
Connection.afterCompletion = afterCompletion
class _DB(object):
"""
......
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