Commit 4a4d2e64 by 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
1 parent d87f899b
...@@ -126,8 +126,10 @@ class Storage(BaseStorage.BaseStorage, ...@@ -126,8 +126,10 @@ class Storage(BaseStorage.BaseStorage,
return self.app.tpc_abort(transaction=transaction) return self.app.tpc_abort(transaction=transaction)
def tpc_finish(self, transaction, f=None): 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) tryToResolveConflict=self.tryToResolveConflict, f=f)
self._snapshot_tid = add64(tid, 1)
return tid
@check_read_only @check_read_only
def store(self, oid, serial, data, version, transaction): def store(self, oid, serial, data, version, transaction):
...@@ -209,9 +211,6 @@ class Storage(BaseStorage.BaseStorage, ...@@ -209,9 +211,6 @@ class Storage(BaseStorage.BaseStorage,
raise KeyError raise KeyError
def sync(self, force=True): 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 # Increment by one, as we will use this as an excluded upper
# bound (loadBefore). # bound (loadBefore).
self._snapshot_tid = add64(self.lastTransaction(), 1) self._snapshot_tid = add64(self.lastTransaction(), 1)
......
...@@ -51,10 +51,10 @@ if needs_patch: ...@@ -51,10 +51,10 @@ if needs_patch:
Connection.tpc_finish = tpc_finish Connection.tpc_finish = tpc_finish
try: try:
if Connection._nexedi_fix != 1: if Connection._nexedi_fix != 2:
raise Exception("A different ZODB fix is already applied") raise Exception("A different ZODB fix is already applied")
except AttributeError: except AttributeError:
Connection._nexedi_fix = 1 Connection._nexedi_fix = 2
# Whenever an connection is opened (and there's usually an existing one # Whenever an connection is opened (and there's usually an existing one
# in DB pool that can be reused) whereas the transaction is already # in DB pool that can be reused) whereas the transaction is already
...@@ -88,6 +88,16 @@ if needs_patch: ...@@ -88,6 +88,16 @@ if needs_patch:
Connection_open = Connection.open Connection_open = Connection.open
Connection.open = 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): class _DB(object):
""" """
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!