Random_Walk has asked for the wisdom of the Perl Monks concerning the following question:
Good Day Fair Monks,
I am using Storable and every so often it all goes pear shaped.
Magic number checking on storable file failed at /usr/localperl/lib/5.18.2/x86_64-linux-thread-multi/Storable.pm line 380 ...
My code runs every five minutes, and will happily store about 5 samples, then it throws the above and dumps core. The store file is zero bytes after that event. When things are good I see these details.
> file itm6_linux_server.memstore > itm6_linux_server.memstore: perl Storable (v0.7) data (major 2) (min +or 9) # from print Dumper Storable::file_magic 'hdrsize' => 19, 'ptrsize' => 8, 'byteorder' => '12345678', 'intsize' => 4, 'file' => 'itm6_linux_server.memstore', 'longsize' => 8, 'netorder' => 0, 'minor' => 9, 'version_nv' => '2.009', 'major' => 2, 'nvsize' => 8, 'version' => '2.9' > ls -l itm6_linux_server.memstore -rw-rw-rw- 1 root root 2514 May 1 16:25 itm6_linux_server.memstore >perl -v This is perl 5, version 18, subversion 2 (v5.18.2) built for x86_64-li +nux-thread-multi
The amount of data is not massive, It currently has 5 records in there, and is 2026 Bytes. The Data I am storing is a hash/array structure, 5 levels at its deepest.
I'm using lock_store and lock_retrieve to get at it, as the script runs on a schedule, as well as me running it every so often for development and debug. The script uses a file lock to guard against multiple runs anyway. I just added the lock_ versions when I hit this error. Did not help. It is only being accessed on the one machine, with the one version of Perl
Any ideas what could be wrong. The code is long and complex. So building a small test case will be a rather long winded process. If there are any known gotchas with Storable I would love a pointer.
All the code is massive. But here are my retrieve and store routines
sub getMem { my $self = shift; my $confID = shift; $confID = $self->{_itm6_lib_gen}->{_CONFID} unless defined $confID +; my $mem = {}; # default to an empty one my $local_store = "local_$confID.memstore"; if (-e $local_store) { eval { $mem = lock_retrieve $local_store }; if ($@) { $self->{_logger}->trace( 1, "getMem: Reading store failed: + $@"); print "getMem: Reading store failed: $@\n"; } } else { # print "$local_store not found\n"; } push @{ $self->{_file_to_write} }, [$mem, $local_store]; # note we + need to write this return $mem; } # Saving is done in DESTROY sub DESTROY { my $self = shift; for (@{ $self->{_file_to_write} }) { my ($mem, $store) = @$_; lock_store ($mem, $store); } }
Cheers,
R.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Storable dumping core
by RichardK (Parson) on May 01, 2015 at 16:31 UTC | |
by Random_Walk (Prior) on May 05, 2015 at 09:10 UTC |