Commit 20f81caa authored by Jim Fulton's avatar Jim Fulton

require the storage lock in lastTransaction.

This is required (or maybe strongly implied) by the IStorage interface.

Also, rearrange the order of operations in _process_invalidations.

Each of these changes avoid a potential race when a connection starts
a transaction while invalidateTransaction is being called. Basically,
we don't want a connection to get a lastTransaction corresponding to
invalidations it hasn't processed.

This neither fixes nor provokes any test failures. :) The need for
this change was discovered via code inspection. It's hard to see how
to test the race without getting being insanely whitebox.
parent d957ff3e
......@@ -1119,7 +1119,8 @@ class ClientStorage(object):
self._tpc_cond.release()
def lastTransaction(self):
return self._cache.getLastTid()
with self._lock:
return self._cache.getLastTid()
def tpc_abort(self, txn):
"""Storage API: abort a transaction."""
......@@ -1473,11 +1474,12 @@ class ClientStorage(object):
if oid == self._load_oid:
self._load_status = 0
self._cache.invalidate(oid, tid)
self._cache.setLastTid(tid)
if self._db is not None:
self._db.invalidate(tid, oids)
self._cache.setLastTid(tid)
# The following are for compatibility with protocol version 2.0.0
def invalidateTrans(self, oids):
......
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