Commit c5e65740 authored by Jim Fulton's avatar Jim Fulton

Changed loadBefore to operate more like load behaved, especially

  with regard to the load lock.  This allowes ZEO to work with the
  upcoming ZODB 5, which used loadbefore rather than load.

  Reimplemented load using loadBefore, this testing loadBefore
  extensively via existing tests.
parent ec370c85
...@@ -4,6 +4,15 @@ Changelog ...@@ -4,6 +4,15 @@ Changelog
4.2.0 (unreleased) 4.2.0 (unreleased)
------------------ ------------------
- Changed loadBefore to operate more like load behaved, especially
with regard to the load lock. This allowes ZEO to work with the
upcoming ZODB 5, which used loadbefore rather than load.
Reimplemented load using loadBefore, this testing loadBefore
extensively via existing tests.
- Fixed: the ZEO cache loadBefore method failed to utilize current data.
- Drop support for Python 2.6 and 3.2. - Drop support for Python 2.6 and 3.2.
4.2.0b1 (2015-06-05) 4.2.0b1 (2015-06-05)
......
...@@ -53,6 +53,9 @@ from ZODB import utils ...@@ -53,6 +53,9 @@ from ZODB import utils
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
# max signed 64-bit value ~ infinity :) Signed cuz LBTree and TimeStamp
m64 = b'\x7f\xff\xff\xff\xff\xff\xff\xff'
try: try:
from ZODB.ConflictResolution import ResolvedSerial from ZODB.ConflictResolution import ResolvedSerial
except ImportError: except ImportError:
...@@ -819,75 +822,37 @@ class ClientStorage(object): ...@@ -819,75 +822,37 @@ class ClientStorage(object):
otherwise a KeyError is raised. otherwise a KeyError is raised.
""" """
self._lock.acquire() # for atomic processing of invalidations result = self.loadBefore(oid, m64)
try: if result is None:
t = self._cache.load(oid) raise POSException.POSKeyError(oid)
if t: return result[:2]
return t
finally: def loadBefore(self, oid, tid):
self._lock.release() """Load the object data written before a transaction id
"""
with self._lock: # for atomic processing of invalidations
result = self._cache.loadBefore(oid, tid)
if result:
return result
if self._server is None: if self._server is None:
raise ClientDisconnected() raise ClientDisconnected()
self._load_lock.acquire() with self._load_lock:
try: with self._lock:
self._lock.acquire()
try:
self._load_oid = oid self._load_oid = oid
self._load_status = 1 self._load_status = 1
finally:
self._lock.release()
data, tid = self._server.loadEx(oid)
self._lock.acquire() # for atomic processing of invalidations
try:
if self._load_status:
self._cache.store(oid, tid, None, data)
self._load_oid = None
finally:
self._lock.release()
finally:
self._load_lock.release()
return data, tid result = self._server.loadBefore(oid, tid)
def loadBefore(self, oid, tid): if result:
self._lock.acquire() with self._lock: # for atomic processing of invalidations
try: if self._load_status:
t = self._cache.loadBefore(oid, tid) data, tid, end = result
if t is not None: self._cache.store(oid, tid, end, data)
return t self._load_oid = None
finally:
self._lock.release()
t = self._server.loadBefore(oid, tid)
if t is None:
return None
data, start, end = t
if end is None:
# This method should not be used to get current data. It
# doesn't use the _load_lock, so it is possble to overlap
# this load with an invalidation for the same object.
# If we call again, we're guaranteed to get the
# post-invalidation data. But if the data is still
# current, we'll still get end == None.
# Maybe the best thing to do is to re-run the test with
# the load lock in the case. That's slow performance, but
# I don't think real application code will ever care about
# it.
return data, start, end
self._lock.acquire()
try:
self._cache.store(oid, start, end, data)
finally:
self._lock.release()
return data, start, end return result
def new_oid(self): def new_oid(self):
"""Storage API: return a new object identifier.""" """Storage API: return a new object identifier."""
......
...@@ -242,19 +242,24 @@ class Connection(smac.SizedMessageAsyncConnection, object): ...@@ -242,19 +242,24 @@ class Connection(smac.SizedMessageAsyncConnection, object):
# Undone oid info returned by vote. # Undone oid info returned by vote.
# #
# Z3101 -- checkCurrentSerialInTransaction # Z3101 -- checkCurrentSerialInTransaction
#
# Z4 -- checkCurrentSerialInTransaction
# No-longer call load.
# Protocol variables: # Protocol variables:
# Our preferred protocol. # Our preferred protocol.
current_protocol = b"Z3101" current_protocol = b"Z4"
# If we're a client, an exhaustive list of the server protocols we # If we're a client, an exhaustive list of the server protocols we
# can accept. # can accept.
servers_we_can_talk_to = [b"Z308", b"Z309", b"Z310", current_protocol] servers_we_can_talk_to = [b"Z308", b"Z309", b"Z310", b"Z3101",
current_protocol]
# If we're a server, an exhaustive list of the client protocols we # If we're a server, an exhaustive list of the client protocols we
# can accept. # can accept.
clients_we_can_talk_to = [ clients_we_can_talk_to = [
b"Z200", b"Z201", b"Z303", b"Z308", b"Z309", b"Z310", current_protocol] b"Z200", b"Z201", b"Z303", b"Z308", b"Z309", b"Z310", b"Z3101",
current_protocol]
# This is pretty excruciating. Details: # This is pretty excruciating. Details:
# #
......
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