[Zodb-checkins] CVS: StandaloneZODB/ZODB - FileStorage.py:1.71.2.6
Jeremy Hylton
jeremy@zope.com
Thu, 8 Nov 2001 11:50:30 -0500
Update of /cvs-repository/StandaloneZODB/ZODB
In directory cvs.zope.org:/tmp/cvs-serv31976/ZODB
Modified Files:
Tag: jeremy-Standby-branch
FileStorage.py
Log Message:
Fix seek-to-starting-transaction bug in FileIterator.
The iterator wasn't assigning self._pos, which was required in order
to get the actual iterator -- the next() method -- to start at the
offset of the proper starting transaction.
Replace lots of uses of variable name with self._file_name to avoid
passing the name around.
=== StandaloneZODB/ZODB/FileStorage.py 1.71.2.5 => 1.71.2.6 ===
self._file.seek(self._pos)
while 1:
+ self._pos = self._file.tell()
h = self._file.read(16)
if len(h) < 16:
return
tid, stl = unpack(">8s8s", h)
if tid >= start:
- self._file.seek(-16, 1)
return
tl = U64(stl)
- self._file.seek(tl - 8)
+ self._file.seek(tl - 8, 1)
rtl = self._file.read(8)
if rtl != stl:
pos = self._file.tell() - 8
- panic("%s has inconsistent transaction length at %s",
- self._file.name, pos)
+ panic("%s has inconsistent transaction length at %s "
+ "(%s != %s)",
+ self._file.name, pos, rtl, stl)
def next(self, index=0):
file=self._file
@@ -2092,7 +2093,7 @@
if el < 0: el=t32-el
if tid <= self._ltid:
- warn("%s time-stamp reduction at %s", name, pos)
+ warn("%s time-stamp reduction at %s", self._file.name, pos)
self._ltid=tid
tl=U64(stl)
@@ -2102,11 +2103,12 @@
# cleared. They may also be corrupted,
# in which case, we don't want to totally lose the data.
warn("%s truncated, possibly due to damaged records at %s",
- name, pos)
+ self._file.name, pos)
break
if status not in ' up':
- warn('%s has invalid status, %s, at %s', name, status, pos)
+ warn('%s has invalid status, %s, at %s', self._file.name,
+ status, pos)
if tl < (23+ul+dl+el):
# We're in trouble. Find out if this is bad data in
@@ -2120,14 +2122,15 @@
# reasonable:
if self._file_size - rtl < pos or rtl < 23:
nearPanic('%s has invalid transaction header at %s',
- name, pos)
+ self._file.name, pos)
warn("It appears that there is invalid data at the end of "
"the file, possibly due to a system crash. %s "
"truncated to recover from bad data at end."
- % name)
+ % self._file.name)
break
else:
- warn('%s has invalid transaction header at %s', name, pos)
+ warn('%s has invalid transaction header at %s',
+ self._file.name, pos)
break
if self._stop is not None:
@@ -2146,7 +2149,7 @@
h=read(8)
if h != stl:
panic('%s has inconsistent transaction length at %s',
- name, pos)
+ self._file.name, pos)
pos=tend+8
continue
@@ -2172,7 +2175,7 @@
h=read(8)
if h != stl:
warn("%s redundant transaction length check failed at %s",
- name, pos)
+ self._file.name, pos)
break
self._pos=pos+8