mldbm error

Discussion in 'Perl Misc' started by JS, Oct 31, 2003.

  1. JS

    JS Guest

    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.
     
    JS, Oct 31, 2003
    #1
    1. Advertising

  2. JS

    Ben Morrow Guest

    wrote:
    > 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}";
    > }
    > }
    >

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

    <snip>
    > 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

    --
    If you put all the prophets, | You'd have so much more reason
    Mystics and saints | Than ever was born
    In one room together, | Out of all of the conflicts of time.
    |----------------+---------------| The Levellers, 'Believers'
     
    Ben Morrow, Oct 31, 2003
    #2
    1. Advertising

  3. JS

    JS Guest

    Ben Morrow wrote:
    > wrote:
    >
    >>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}";
    >> }
    >>}
    >>

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

    >
    > <snip>
    >
    >> 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
    >


    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.
     
    JS, Oct 31, 2003
    #3
  4. JS

    Ben Morrow Guest

    wrote:
    > 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

    --
    It will be seen... that the Erwhonians are a meek and long-suffering people,
    easily led by the nose, and quick to offer up common sense at the shrine of
    logic, when a philosopher arises among them who... convinc[es] them that their
    ....institutions are not based on... morality. [Samuel Butler]
     
    Ben Morrow, Oct 31, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Mott

    MLDBM

    Jeff Mott, Aug 12, 2003, in forum: Perl Misc
    Replies:
    4
    Views:
    100
    simonis
    Aug 13, 2003
  2. Brian Greenfield

    HoH and MLDBM problems

    Brian Greenfield, Aug 26, 2003, in forum: Perl Misc
    Replies:
    4
    Views:
    152
    Bob Walton
    Sep 17, 2003
  3. Mark Ng

    MLDBM error

    Mark Ng, Nov 30, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    104
    Mark Ng
    Nov 30, 2004
  4. Replies:
    0
    Views:
    129
  5. Using MLDBM on objects?

    , Jul 1, 2005, in forum: Perl Misc
    Replies:
    2
    Views:
    176
    Anno Siegel
    Jul 1, 2005
Loading...

Share This Page