[Zope] POSKeyError, help, please.

Dieter Maurer dieter@handshake.de
Mon, 24 Mar 2003 19:50:48 +0100


Stefan A. Nagey wrote at 2003-3-23 15:23 -0500:
 > I've been struggling with this one non-stop since last night.
 > 
 > I work at an ISP, we keep our customer records in zope.
 > 
 > Somehow, i seem to have lost records for nearly 1/4 of our customers.
 > 
 > I've tried deleting the index, packing the DB, exporting and then 
 > importing into a fresh Data.fs, using fsrecover.py
 > 
 > i've also tried fsrefs.py, which tells me that i'm missing a bunch of 
 > objects.
 > 
 > The size of my Data.fs is prettymuch unchanged, which might suggest 
 > that the data is still there, but how do i get to it?

Provided you have enough disk space, use
"fsdump" to get a textual representation of your "Data.fs".

You will see object records containing "oid" values.
These are hexadecimal representations of the values reported
in "POSKeyError" (side node: why do "POSKeyError" not report
the hexadecimal value?).
To convert between hexadecimal and textual representation,
you can use "U64" and "p64" from "ZODB.utils".
"U64" converts a textual representation into a long
and "p64" converts a long into a textual representation.

Use a text editor to find the last reference to your missing
object in the textual
representation of your "Data.fs" (obtained by "fsdump").
That's the last time, the object has been modified.

Look at the next transaction record. It has a "tid" field.
Note the "offset" for this transaction.
Truncate your "Data.fs" to the given offset (in a copy, of course).
Start Zope with the truncated "Data.fs".
Your object should be there.
Export it (you will get the state as it was at the time of the
transaction where you have cut "Data.fs"; you may try to use
later transaction, to be more up-to-date).

Import the exported object into a Data.fs where you want to 
work with.



Dieter