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.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.
4.2.0b1 (2015-06-05)
......
......@@ -53,6 +53,9 @@ from ZODB import utils
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:
from ZODB.ConflictResolution import ResolvedSerial
except ImportError:
......@@ -819,75 +822,37 @@ class ClientStorage(object):
otherwise a KeyError is raised.
"""
self._lock.acquire() # for atomic processing of invalidations
try:
t = self._cache.load(oid)
if t:
return t
finally:
self._lock.release()
result = self.loadBefore(oid, m64)
if result is None:
raise POSException.POSKeyError(oid)
return result[:2]
def loadBefore(self, oid, tid):
"""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:
raise ClientDisconnected()
self._load_lock.acquire()
try:
self._lock.acquire()
try:
with self._load_lock:
with self._lock:
self._load_oid = oid
self._load_status = 1
finally:
self._lock.release()
data, tid = self._server.loadEx(oid)
result = self._server.loadBefore(oid, tid)
self._lock.acquire() # for atomic processing of invalidations
try:
if result:
with self._lock: # for atomic processing of invalidations
if self._load_status:
self._cache.store(oid, tid, None, data)
data, tid, end = result
self._cache.store(oid, tid, end, data)
self._load_oid = None
finally:
self._lock.release()
finally:
self._load_lock.release()
return data, tid
def loadBefore(self, oid, tid):
self._lock.acquire()
try:
t = self._cache.loadBefore(oid, tid)
if t is not None:
return t
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):
"""Storage API: return a new object identifier."""
......
......@@ -242,19 +242,24 @@ class Connection(smac.SizedMessageAsyncConnection, object):
# Undone oid info returned by vote.
#
# Z3101 -- checkCurrentSerialInTransaction
#
# Z4 -- checkCurrentSerialInTransaction
# No-longer call load.
# Protocol variables:
# Our preferred protocol.
current_protocol = b"Z3101"
current_protocol = b"Z4"
# If we're a client, an exhaustive list of the server protocols we
# 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
# can accept.
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:
#
......
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