Commit d4b12439 authored by Jeremy Hylton's avatar Jeremy Hylton

Fix cache invalidation abortVersion() and commitVersion().

The invalidated oids (and versions) get written to the tempfile, and
are invalidated during the tpc_finish().
parent a5f34eb9
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
############################################################################## ##############################################################################
"""Network ZODB storage client """Network ZODB storage client
""" """
__version__='$Revision: 1.29 $'[11:-2] __version__='$Revision: 1.30 $'[11:-2]
import struct, time, os, socket, string, Sync, zrpc, ClientCache import struct, time, os, socket, string, Sync, zrpc, ClientCache
import tempfile, Invalidator, ExtensionClass, thread import tempfile, Invalidator, ExtensionClass, thread
...@@ -289,8 +289,9 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage): ...@@ -289,8 +289,9 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage):
self._lock_acquire() self._lock_acquire()
try: try:
oids=self._call('abortVersion', src, self._serial) oids=self._call('abortVersion', src, self._serial)
invalidate=self._cache.invalidate vlen = pack(">H", len(src))
for oid in oids: invalidate(oid, src) for oid in oids:
self._tfile.write("i%s%s%s" % (oid, vlen, src))
return oids return oids
finally: self._lock_release() finally: self._lock_release()
...@@ -307,12 +308,15 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage): ...@@ -307,12 +308,15 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage):
oids=self._call('commitVersion', src, dest, self._serial) oids=self._call('commitVersion', src, dest, self._serial)
invalidate=self._cache.invalidate invalidate=self._cache.invalidate
if dest: if dest:
vlen = pack(">H", len(src))
# just invalidate our version data # just invalidate our version data
for oid in oids: invalidate(oid, src) for oid in oids:
self._tfile.write("i%s%s%s" % (oid, vlen, src))
else: else:
vlen = pack(">H", len(dest))
# dest is '', so invalidate version and non-version # dest is '', so invalidate version and non-version
for oid in oids: invalidate(oid, dest) for oid in oids:
self._tfile.write("i%s%s%s" % (oid, vlen, dest))
return oids return oids
finally: self._lock_release() finally: self._lock_release()
...@@ -385,8 +389,10 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage): ...@@ -385,8 +389,10 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage):
data, version, self._serial) data, version, self._serial)
write=self._tfile.write write=self._tfile.write
write(oid+pack(">HI", len(version), len(data))+version) buf = string.join(("s", oid,
write(data) pack(">HI", len(version), len(data)),
version, data), "")
write(buf)
if self._serials: if self._serials:
s=self._serials s=self._serials
...@@ -508,23 +514,32 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage): ...@@ -508,23 +514,32 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage):
seek(0) seek(0)
i=0 i=0
while i < size: while i < size:
oid=read(8) opcode=read(1)
s=seriald[oid] if opcode == "s":
h=read(6) oid=read(8)
vlen, dlen = unpack(">HI", h) s=seriald[oid]
if vlen: v=read(vlen) h=read(6)
else: v='' vlen, dlen = unpack(">HI", h)
p=read(dlen) if vlen: v=read(vlen)
if len(p) != dlen: else: v=''
raise ClientStorageError, ( p=read(dlen)
"Unexpected end of file in client storage " if len(p) != dlen:
"temporary file." raise ClientStorageError, (
) "Unexpected end of file in client storage "
if s==ResolvedSerial: "temporary file."
cache.invalidate(oid, v) )
else: if s==ResolvedSerial:
update(oid, s, v, p) cache.invalidate(oid, v)
i=i+14+vlen+dlen else:
update(oid, s, v, p)
i=i+15+vlen+dlen
elif opcode == "i":
oid=read(8)
h=read(2)
vlen=unpack(">H", h)[0]
v=read(vlen)
self._cache.invalidate(oid, v)
i=i+11+vlen
seek(0) seek(0)
......
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