Commit 58d0299a authored by Jim Fulton's avatar Jim Fulton

The following scenario could lead to strange and serious errors:

  - Restart or pack Zope, causing an index to get written

  - Undo some transactions

  - Shutdown Zope ungracefully (e.g. kill)

When Zope comes up, the index points to undone records for some
objects. This can lead to all sorts of problems. :(

To overcome this problem, we now remove the index after an
undo.

This increases the likelyhood that it will take longer to restart
next time, but reduces the chance of a bad index.
parent 0475cb1d
...@@ -184,7 +184,7 @@ ...@@ -184,7 +184,7 @@
# may have a back pointer to a version record or to a non-version # may have a back pointer to a version record or to a non-version
# record. # record.
# #
__version__='$Revision: 1.30 $'[11:-2] __version__='$Revision: 1.31 $'[11:-2]
import struct, time, os, bpthread, string, base64, sys import struct, time, os, bpthread, string, base64, sys
from struct import pack, unpack from struct import pack, unpack
...@@ -349,6 +349,11 @@ class FileStorage(BaseStorage.BaseStorage): ...@@ -349,6 +349,11 @@ class FileStorage(BaseStorage.BaseStorage):
os.rename(tmp_name, index_name) os.rename(tmp_name, index_name)
except: pass except: pass
def _clear_index(self):
index_name=self.__name__+'.index'
if os.path.exists(index_name):
os.unlink(index_name)
def _sane(self, index, pos): def _sane(self, index, pos):
"""Sanity check saved index data by reading the last undone trans """Sanity check saved index data by reading the last undone trans
...@@ -711,6 +716,7 @@ class FileStorage(BaseStorage.BaseStorage): ...@@ -711,6 +716,7 @@ class FileStorage(BaseStorage.BaseStorage):
def undo(self, transaction_id): def undo(self, transaction_id):
self._lock_acquire() self._lock_acquire()
try: try:
self._clear_index()
transaction_id=base64.decodestring(transaction_id+'==\n') transaction_id=base64.decodestring(transaction_id+'==\n')
tid, tpos = transaction_id[:8], u64(transaction_id[8:]) tid, tpos = transaction_id[:8], u64(transaction_id[8:])
packt=self._packt packt=self._packt
......
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