mldbm error

J

JS

Hi,

I have some code to print from a multi-level hash that has been stored
using mldbm:

use MLDBM qw(DB_File Storable);
tie my %appstaffwk, 'MLDBM', $appstaffwkdb or die $!;

foreach $app (keys %appstaffwk){
$hashref=$appstaffwk{$app};
foreach $staffno (keys %$hashref){
print "\n$app:$staffno:$hashref->{$staffno}";
}
}

This seems to work fine on the other db files I made, but when I run it
on the following file:

-rw-r----- 1 32766 B8 1056768 Oct 31 09:35 appstaff-yr2003.db

It gives me the below error (when I have diagnostics switched on):

eBasis:818829:1
eBasis:106831:1
eBasis:738496:1
eBasis:654168:1
eBasis:652566:1
eBasis:705210:1Uncaught exception from user code:
Uncaught exception from user code:
Storable binary image v24.8 more recent than I am (v2.6) at
blib/lib/Storable.pm (autosplit into blib/lib/auto/Storable/thaw.al)
line 364.
eval {...} called at blib/lib/Storable.pm (autosplit into
blib/lib/auto/Storable/thaw.al) line 364

Storable::thaw('1^HM-^A^@^@^@^F813032^HM-^A^@^@^@^F813034^HM-^A^@^@^@^F881080^HM-^A^@^@^@^F740209^HM-^A^@^@^@^F697580^HM-^A^@...')
called at
/usr/local/perl-5.6.1/lib/site_perl/5.6.1/MLDBM/Serializer/Storable.pm
line 27

MLDBM::Serializer::Storable::deserialize('MLDBM::Serializer::Storable=HASH(0x20257444)',
'1^HM-^A^@^@^@^F813032^HM-^A^@^@^@^F813034^HM-^A^@^@^@^F881080^HM-^A^@^@^@^F740209^HM-^A^@^@^@^F697580^HM-^A^@...')
called at /usr/local/perl-5.6.1/lib/site_perl/5.6.1/MLDBM.pm line 155
MLDBM::FETCH('MLDBM=HASH(0x200347e4)', 'BSafe') called at
../show_appstaffwk.pl line 39, at
/usr/local/perl-5.6.1/lib/site_perl/5.6.1/MLDBM/Serializer/Storable.pm
line 27
Carp::croak('Uncaught exception from user code:^J^IStorable
binary image v24.8 ...') called at blib/lib/Storable.pm (autosplit into
blib/lib/auto/Storable/logcroak.al) line 71
Storable::logcroak('Uncaught exception from user
code:^J^IStorable binary image v24.8 ...') called at
blib/lib/Storable.pm (autosplit into blib/lib/auto/Storable/thaw.al)
line 365

Storable::thaw('1^HM-^A^@^@^@^F813032^HM-^A^@^@^@^F813034^HM-^A^@^@^@^F881080^HM-^A^@^@^@^F740209^HM-^A^@^@^@^F697580^HM-^A^@...')
called at
/usr/local/perl-5.6.1/lib/site_perl/5.6.1/MLDBM/Serializer/Storable.pm
line 27

MLDBM::Serializer::Storable::deserialize('MLDBM::Serializer::Storable=HASH(0x20257444)',
'1^HM-^A^@^@^@^F813032^HM-^A^@^@^@^F813034^HM-^A^@^@^@^F881080^HM-^A^@^@^@^F740209^HM-^A^@^@^@^F697580^HM-^A^@...')
called at /usr/local/perl-5.6.1/lib/site_perl/5.6.1/MLDBM.pm line 155
MLDBM::FETCH('MLDBM=HASH(0x200347e4)', 'BSafe') called at
../show_appstaffwk.pl line 39

I'm really stuck on this. Could anyone help me out please? Thanks.

JS.
 
B

Ben Morrow

I have some code to print from a multi-level hash that has been stored
using mldbm:

use MLDBM qw(DB_File Storable);
tie my %appstaffwk, 'MLDBM', $appstaffwkdb or die $!;

foreach $app (keys %appstaffwk){
$hashref=$appstaffwk{$app};
foreach $staffno (keys %$hashref){
print "\n$app:$staffno:$hashref->{$staffno}";
}
}
It gives me the below error (when I have diagnostics switched on):
Uncaught exception from user code:
Storable binary image v24.8 more recent than I am (v2.6) at
blib/lib/Storable.pm (autosplit into blib/lib/auto/Storable/thaw.al)
line 364.

I'm sorry to say this, but it looks to me like your database is
corrupt. Storable seems to think that the data stored in the database
was created by Storable.pm v24.8, but that won't be written for
really *quite* some time...

What happens when you run the following:

use Data::Dumper;
use MLDBM qw/DB_File Storable/;

tie my %appstaffwk, MLDBM => $appstaffwkdb or die "tie failed: $!";

for (keys %appstaffwk) {
eval {
print Dumper $appstaffwk{$_};
1;
} or warn "\$appstaffwk{$_} is corrupt!\n";
}

__END__

The eval{} is there so that if some of the entries are corrupt and
others aren't, it'll carry on and try them all rather than dieing
after the first.

Ben
 
J

JS

Ben said:
I'm sorry to say this, but it looks to me like your database is
corrupt. Storable seems to think that the data stored in the database
was created by Storable.pm v24.8, but that won't be written for
really *quite* some time...

What happens when you run the following:

use Data::Dumper;
use MLDBM qw/DB_File Storable/;

tie my %appstaffwk, MLDBM => $appstaffwkdb or die "tie failed: $!";

for (keys %appstaffwk) {
eval {
print Dumper $appstaffwk{$_};
1;
} or warn "\$appstaffwk{$_} is corrupt!\n";
}

__END__

The eval{} is there so that if some of the entries are corrupt and
others aren't, it'll carry on and try them all rather than dieing
after the first.

Ben

Thanks, you were right, the database was corrupted. I'm going to start
over again.

I just wondered, when I store my hash %appstaffwk which has 2 levels -
$appstaffwk{$app}{$staffno} my script which usually runs in 1 minute,
takes about 30 minutes. Is that normal? This is the code I've been using
to store the hash:

my $tmp=$appstaffwk{$app};
if (! defined $tmp->{$staffno}){
$tmp->{$staffno}=1;
$appstaffwk{$app}=$tmp;
}

It doesn't work if you just do:

$appstaffwk{$app}{$staffno}=1;

Is there anything I can do to make the hash storage faster?

Thanks,

JS.
 
B

Ben Morrow

I just wondered, when I store my hash %appstaffwk which has 2 levels -
$appstaffwk{$app}{$staffno} my script which usually runs in 1 minute,
takes about 30 minutes. Is that normal?

If this is the only hash which has more than one level, then this is
the only one which actually uses MLDBM as opposed to simply using
DB_File: so yes, I would expect it to be slower. How much slower I
couldn't say, having not used MLDBM. I would not expect that adding
more levels would cause any further decrease in speed, though.
This is the code I've been using to store the hash:

my $tmp=$appstaffwk{$app};
if (! defined $tmp->{$staffno}){
$tmp->{$staffno}=1;
$appstaffwk{$app}=$tmp;
}

It doesn't work if you just do:

$appstaffwk{$app}{$staffno}=1;

Is there anything I can do to make the hash storage faster?

Read the WARNINGS section at the end of perldoc MLDBM.

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top