Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Recovering from a corrupt storable file

by chanakya (Friar)
on Mar 30, 2010 at 12:06 UTC ( #831832=perlquestion: print w/replies, xml ) Need Help??

chanakya has asked for the wisdom of the Perl Monks concerning the following question:

Dear All

I have a Perl script which creates/update persistence cache file on the disk using Storable.

Lately I have observed an issue. Basically one of the members
had killed the script in between and this has corrupted the persistence cache and I'm not able to recover from that point.

We store the counts of processed files as well as individual counts per each hour into the cache file. This is a hash ref that gets stored.
I'd like to know is there any fallback mechanism or any technique which can get the data from the corrupted cache file.

Thank you for your time.
  • Comment on Recovering from a corrupt storable file

Replies are listed 'Best First'.
Re: Recovering from a corrupt storable file
by moritz (Cardinal) on Mar 30, 2010 at 13:01 UTC

    I don't think you can recover such a file with reasonable effort.

    But since it's just a cache: delete it, then the application will re-generate it.

    If this happens more often and turns out to be a problem for you, you need some transaction-safe system like a proper database.

    Perl 6 - links to (nearly) everything that is Perl 6.
Re: Recovering from a corrupt storable file
by SuicideJunkie (Vicar) on Mar 30, 2010 at 12:51 UTC

    By "corrupted", I expect you mean "cut off halfway through writing the file", in which case, you've deleted about half the info.

    I presume your script doesn't write to a temporary file and ensure it has finished successfully before copying it over the real one? Have you talked to your server guys about pulling out the backup tapes for the last week and rebuilding/restarting from there?

Re: Recovering from a corrupt storable file
by chanakya (Friar) on Mar 30, 2010 at 16:49 UTC
    I did not want the dependency of database with the Perl script, which lead me to use the Persistence cache mechanism.
    Yes, my script doesn't write to a temporary file may be this is one of the improvement which I can
    think over to avoid similar situations

    Appreciate your suggestions.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://831832]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (1)
As of 2022-11-26 23:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?