I have a perl script deployed on many hundreds of servers at work. Occassionally, on a few servers, I see two different errors when trying to retrieve() a stored file (these different failure modes occur on different servers):
(1) "File is not a perl storable"
and
(2) "Byte order is not compatible"
This is NOT because I am moving stored files from system to system, perl version to perl version, etc. The file is saved using store() in one run of the script. Then, five minutes later the exact same scripts runs again (this is all under cron control), and tries to retrieve what it stored during its previous run. This is not trying to move/reuse a stored file across different OS'es/versions. It is the same server, running the same version of perl, running the same script, using same version of the Storable.pm module, etc.
There is no chance the stored file is being created/updated by any other process that could be corrupting it. It is very uniquely named, and only writeable by root.
On most of the 800+ servers this script is deployed on, Storable.pm works just fine. But on a handful of servers, I'm seeing these unexpected errors. Any ideas what may be going on?
If have temporarily worked around this by doing the following (using eval to trap the fatal error), but this is just hiding the problem, not fixing it:
Code:
store(\%current, $filename);
... the later, in the next run of the script
if (-e $filename) {
eval {
$previous = retrieve($filename);
};
if ($@) {
unlink($filename)
$previous = {};
}
}
else {
$previous = {};
}