recover pickled data: pickle data was truncated

Avi Gross avigross at verizon.net
Wed Dec 29 13:54:14 EST 2021


I am not an expert on the topic but my first reaction is it depends on how
the data is corrupted and we do not know that. So I am addressing a more
general concept here.

Some algorithms break if a single byte or even bit changes and nothing
beyond that point makes sense. Many encryption techniques are like that and
adding or deleting a byte might throw things off completely. 

But if your problem is that two processes or threads wrote interleaved and
yet resulted in an output of a similar size, then, yes, in some cases some
of the data could be retrieved, albeit be fragmentary and unreliable. If
they both included say a data structure with names and phone numbers, it is
possible you get two partial or complete copies and maybe retrieve a phone
number you can try and see if it works. But the tax authorities might not
react favorably to your recovery of a business expense if it is possible the
currency amount was corrupted and perhaps a few zeroes were appended at the
end.

For some mission-critical purposes, I am sure people have come up with many
ideas including perhaps making multiple copies before an exit spread across
multiple disks and sites or reading the file back in and checking it. But
corruption can happen for many reasons including at the level of the disk it
is written to.

-----Original Message-----
From: Python-list <python-list-bounces+avigross=verizon.net at python.org> On
Behalf Of iMath
Sent: Wednesday, December 29, 2021 10:51 AM
To: python-list at python.org
Subject: Re: recover pickled data: pickle data was truncated

> You have lost the data in that case. 

But I found the size of the file of the shelve data didn't change much, so I
guess the data are still in it , I just wonder any way to recover my data.
-- 
https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list