Commit 6602645f authored by Jim Fulton's avatar Jim Fulton

Don't update the cache lastTid until we've invalidated a value (rather

than before).  It's possible that process shutdown after updating
lastTid but before invalidating the current record could explain some
problems we've seen on restarts.

(This change is made irrelevent by later changes.)
parent b3c1d30e
...@@ -379,10 +379,14 @@ class ClientCache(object): ...@@ -379,10 +379,14 @@ class ClientCache(object):
# recent tid. # recent tid.
@locked @locked
def setLastTid(self, tid): def setLastTid(self, tid):
if self.tid is not None and tid <= self.tid: if (not tid) or (tid == z64):
return
if (self.tid is not None) and (tid <= self.tid):
if tid == self.tid:
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 "
"previous one (%s)" % (u64(tid), "previous one (%s)"
u64(self.tid))) % (u64(tid), u64(self.tid)))
assert isinstance(tid, str) and len(tid) == 8, tid assert isinstance(tid, str) and len(tid) == 8, tid
self.tid = tid self.tid = tid
self.f.seek(len(magic)) self.f.seek(len(magic))
...@@ -631,20 +635,11 @@ class ClientCache(object): ...@@ -631,20 +635,11 @@ class ClientCache(object):
@locked @locked
def invalidate(self, oid, version, tid, server_invalidation=True): def invalidate(self, oid, version, tid, server_invalidation=True):
if tid is not None:
if tid > self.tid:
self.setLastTid(tid)
elif tid < self.tid:
if server_invalidation:
raise ValueError("invalidation tid (%s) must not be less"
" than previous one (%s)" %
(u64(tid), u64(self.tid)))
ofs = self.current.get(oid) ofs = self.current.get(oid)
if ofs is None: if ofs is None:
# 0x10 == invalidate (miss) # 0x10 == invalidate (miss)
self._trace(0x10, oid, version, tid) self._trace(0x10, oid, version, tid)
return return self.setLastTid(tid)
self.f.seek(ofs) self.f.seek(ofs)
read = self.f.read read = self.f.read
...@@ -672,6 +667,8 @@ class ClientCache(object): ...@@ -672,6 +667,8 @@ class ClientCache(object):
# 0x1C = invalidate (hit, saving non-current) # 0x1C = invalidate (hit, saving non-current)
self._trace(0x1C, oid, version, tid) self._trace(0x1C, oid, version, tid)
return self.setLastTid(tid)
## ##
# Generates (oid, serial, version) triples for all objects in the # Generates (oid, serial, version) triples for all objects in the
# cache. This generator is used by cache verification. # cache. This generator is used by cache verification.
......
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