Hello,

I have run into a problem specific to Berkeley 4.0.14 that I hope you 
can help me to diagnose. There are enough other products involved 
that I'm not sure if it's DB's fault or mod_perl's. Here's the setup:

   Linux 7.2 i386
   perl 5.6.1
   apache 1.3.19 with mod_perl 1.25
   DB 4.0.14
   BerkeleyDB 0.18

I'm testing with the Perl script below, with the filename ending 
".mperl" (which, in my configuration, causes it to run as a mod_perl 
registry script).

The problem: Under DB 4.0.14, five lockers get allocated, one during 
each iteration of the loop. The test program will show "Current 
number of lockers" and "Maximum number of lockers so far" both to be 
5. In a production environment, this behavior eventually leads to an 
error, because the maximum number of lockers is reached.

If I either use DB 3.x or even run this from the commandline 
(bypassing mod_perl) under DB 4 the problem goes away: only one 
locker is allocated per loop, and therefore the total number used 
does not increase unexpectedly.

I have already contacted Sleepycat (the makers of DB), but they 
cannot help much, since their experience with mod_perl is limited.

--------- TEST SCRIPT ---------

#!/usr/bin/perl

use strict;
use BerkeleyDB qw( DB_CREATE DB_INIT_MPOOL DB_INIT_CDB );

# Change me to something appropriate for your system
my $dir='/home/httpd/some/directory';

system( "rm $dir/__db* $dir/TESTdb" );

foreach( 1..5 ) {
        my $env = open_env($dir);
        my %hash;
        my $db = open_db( "TESTdb", \%hash, $env );
        untie %hash;
        undef $db;
        undef $env;
}
print "HTTP/1.1 200\nContent-type: text/plain\n\n";
print `db_stat -c -h $dir`;
print "\n";

sub open_env {
        my $env = new BerkeleyDB::Env(
                -Flags=>DB_INIT_MPOOL|DB_INIT_CDB|DB_CREATE,
                -Home=> $_[0],
                );
        die "Could not create env: $! ".$BerkeleyDB::Error. "\n" if !$env;
        return $env;
}

sub open_db {
        my( $file, $Rhash, $env ) = @_;
        my $db_key = tie( %{$Rhash}, 'BerkeleyDB::Btree',
                        -Flags=>DB_CREATE,
                        -Filename=>$file,
                        -Env=>$env );
        die "Can't open $file: $! ".$BerkeleyDB::Error."\n" if !$db_key;
        return $db_key;
}


Dan Wilga                                         [EMAIL PROTECTED]
Web Technology Specialist                     http://www.mtholyoke.edu
Mount Holyoke College                                Tel: 413-538-3027
South Hadley, MA  01075     "I have a bold and cunning plan" - Baldric

Reply via email to