Commit beaad669 authored by Jim Fulton's avatar Jim Fulton

Finish z64-ification of lastTransaction.

parent d30a1ae9
...@@ -1339,25 +1339,25 @@ class ClientStorage(object): ...@@ -1339,25 +1339,25 @@ class ClientStorage(object):
# it should set self._server. If it goes through full cache # it should set self._server. If it goes through full cache
# verification, then endVerify() should self._server. # verification, then endVerify() should self._server.
ltid = server.lastTransaction() server_tid = server.lastTransaction()
if not self._cache: if not self._cache:
logger.info("%s No verification necessary -- empty cache", logger.info("%s No verification necessary -- empty cache",
self.__name__) self.__name__)
if ltid != utils.z64: if server_tid != utils.z64:
self._cache.setLastTid(ltid) self._cache.setLastTid(server_tid)
self.finish_verification() self.finish_verification()
return "empty cache" return "empty cache"
last_inval_tid = self._cache.getLastTid() cache_tid = self._cache.getLastTid()
if last_inval_tid is not None: if cache_tid != utils.z64:
if ltid == last_inval_tid: if server_tid == cache_tid:
logger.info( logger.info(
"%s No verification necessary" "%s No verification necessary"
" (last_inval_tid up-to-date %r)", " (cache_tid up-to-date %r)",
self.__name__, ltid) self.__name__, server_tid)
self.finish_verification() self.finish_verification()
return "no verification" return "no verification"
elif ltid < last_inval_tid: elif server_tid < cache_tid:
message = ("%s Client has seen newer transactions than server!" message = ("%s Client has seen newer transactions than server!"
% self.__name__) % self.__name__)
logger.critical(message) logger.critical(message)
...@@ -1365,23 +1365,24 @@ class ClientStorage(object): ...@@ -1365,23 +1365,24 @@ class ClientStorage(object):
# log some hints about last transaction # log some hints about last transaction
logger.info("%s last inval tid: %r %s\n", logger.info("%s last inval tid: %r %s\n",
self.__name__, last_inval_tid, self.__name__, cache_tid,
tid2time(last_inval_tid)) tid2time(cache_tid))
logger.info("%s last transaction: %r %s", logger.info("%s last transaction: %r %s",
self.__name__, ltid, ltid and tid2time(ltid)) self.__name__, server_tid,
server_tid and tid2time(server_tid))
pair = server.getInvalidations(last_inval_tid) pair = server.getInvalidations(cache_tid)
if pair is not None: if pair is not None:
logger.info("%s Recovering %d invalidations", logger.info("%s Recovering %d invalidations",
self.__name__, len(pair[1])) self.__name__, len(pair[1]))
self.finish_verification(pair) self.finish_verification(pair)
return "quick verification" return "quick verification"
elif ltid != utils.z64: elif server_tid != utils.z64:
# Hm, to have gotten here, the cache is non-empty, but # Hm, to have gotten here, the cache is non-empty, but
# it has no last tid. This doesn't seem like good situation. # it has no last tid. This doesn't seem like good situation.
# We'll have to verify the cache, if we're willing. # We'll have to verify the cache, if we're willing.
self._cache.setLastTid(ltid) self._cache.setLastTid(server_tid)
zope.event.notify(ZEO.interfaces.StaleCache(self)) zope.event.notify(ZEO.interfaces.StaleCache(self))
...@@ -1398,8 +1399,8 @@ class ClientStorage(object): ...@@ -1398,8 +1399,8 @@ class ClientStorage(object):
if self._cache and self._drop_cache_rather_verify: if self._cache and self._drop_cache_rather_verify:
logger.critical("%s dropping stale cache", self.__name__) logger.critical("%s dropping stale cache", self.__name__)
self._cache.clear() self._cache.clear()
if ltid: if server_tid:
self._cache.setLastTid(ltid) self._cache.setLastTid(server_tid)
self.finish_verification() self.finish_verification()
return "cache dropped" return "cache dropped"
......
...@@ -310,7 +310,7 @@ class StorageServer308(StorageServer): ...@@ -310,7 +310,7 @@ class StorageServer308(StorageServer):
def __init__(self, rpc): def __init__(self, rpc):
if rpc.peer_protocol_version == 'Z200': if rpc.peer_protocol_version == 'Z200':
self.lastTransaction = lambda: None self.lastTransaction = lambda: z64
self.getInvalidations = lambda tid: None self.getInvalidations = lambda tid: None
self.getAuthProtocol = lambda: None self.getAuthProtocol = lambda: None
......
...@@ -177,7 +177,7 @@ class ClientCache(object): ...@@ -177,7 +177,7 @@ class ClientCache(object):
# tid for the most recent transaction we know about. This is also # tid for the most recent transaction we know about. This is also
# stored near the start of the file. # stored near the start of the file.
self.tid = None self.tid = z64
# Always the offset into the file of the start of a block. # Always the offset into the file of the start of a block.
# New and relocated objects are always written starting at # New and relocated objects are always written starting at
...@@ -458,7 +458,7 @@ class ClientCache(object): ...@@ -458,7 +458,7 @@ class ClientCache(object):
def setLastTid(self, tid): def setLastTid(self, tid):
if (not tid) or (tid == z64): if (not tid) or (tid == z64):
return return
if (self.tid is not None) and (tid <= self.tid) and self: if (tid <= self.tid) and self._len:
if tid == self.tid: if tid == self.tid:
return # Be a little forgiving return # Be a little forgiving
raise ValueError("new last tid (%s) must be greater than " raise ValueError("new last tid (%s) must be greater than "
......
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