You are here:   » Home » Documentation » Details » How-To » Operation » Home

Repairing corrupt Data Base Objects

Author: Dr. Volker Liebenberg, 2003/12/15

Several reasons may corrupt the ZOPE database, e.g. abnormal system ends or a damaged hard disk. This attracts attention by a so-called POSKeyError, the relevant objects cannot be processed any more. (see also output on prompt/command line resp. nohup.out)

Solution: If ZOPEHOME/lib/python/ZODB/fsrecover.py is not successful, the database may be edited on the prompt level.

#Attention no complete script,
#Parametrisation is requested!
#Enter commands at the Shell/command line
#Set ambient variable
PYTHONPATH=/opt/zope/lib/python;export PYTHONPATH
#Call python-interpreter
ZOPEHOME/bin/python

from Zope import app
from ZODB import POSException 
from OFS import Folder | 
from OFS import DTMLMethod #a(Examples)

root= app() 
obj= root.unrestrictedTraverse('url_to_obj')
for id,val in obj.objectItems():
      try: val.getId()  #Note indentation
      except POSKeyError: break

#(id) now containing the searched object
#Delete the object
obj.manage_delObjects(id)
get_transaction().commit()

#optional (new) application of the object
obj.manage_addFolder('Foldername')
get_transaction().commit()

##################################
#Example for an error message 
#in case of corrupt Data.fs
------
2003-12-12T23:28:11 ERROR(200) 
ZODB Couldn't load state for 
'\x00\x00\x00\x00\x00\nY\xa7'
Traceback (innermost last):
  File /opt/Zope-2.6.1-linux2-x86/lib/python
  /ZODB/Connection.py,line 509, in setstate
  File /opt/Zope-2.6.1-linux2-x86/lib/python
  /ZODB/FileStorage.py,line 650, in load
    (Object: /opt/Zope-2.6.1-linux2-x86/var/Data.fs)
  File /opt/Zope-2.6.1-linux2-x86/lib/python
  /ZODB/FileStorage.py,line 624, in _load
    (Object: /opt/Zope-2.6.1-linux2-x86/var/Data.fs)
POSKeyError: 00000000000a59a7
------

Comment: For a detailed description see the following link 'Editing Data.fs...'. The process is tested under Zope 2.6.1 and works without problems.

Many, many thanks to Dieter Maurer and heureso

References: