Berkeley DB / DB File Concurrence Problem 
Author Message
 Berkeley DB / DB File Concurrence Problem

Hi Folks,

I've been using Berkeley DB 1.86 with Perl DB File as the data engine
for
several CGI sites I've built.  Recently, trying to improve robustness,
I've
started using $db->fd and locking the DB Files with the file handle I
can
then generate.  Ideally, I'd like each of the data objects to be able to

create
a DB_File object that points to the correct db file and lock the file
only
when reading or writing.

The Problem:

when I have multiple objects pointing at the same db file, such as

$db1 = tie ( %HASH1, 'DB_file' , "$file_name1", O_RDWR, undef, $DB_HASH
)
$db2 = tie ( %HASH2, 'DB_file' , "$file_name1", O_RDWR, undef, $DB_HASH
)
$db3 = tie ( %HASH3, 'DB_file' , "$file_name1", O_RDWR, undef, $DB_HASH
)

if I print from any of the objects like so:
my $value1;
print $db1->fetch ( 'key', $value1 )

I get the correct return value from each.

However, if I write to the database like so:
$value2 = 'some value';
$db2->put ( 'key', $value2 );

and then perform a fetch of 'key' from each db object, $db2 fetches the
correct
vslue but $db1 and $db3 do not reflect the updates.

Is there some way to make this work?  I've written put methods that sync

the db object and the db file everytime a write is performed, but this
only
updates the db file to reflect the db object from which the sync was
called,
it does not update all other objects that point to the db file.

Any help would be greatly appreciated.

Thanks.

Michael Jones



Fri, 23 Feb 2001 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Berkeley DB / DB File Concurrence Problem

2. Berkeley DB, DB File on multiple platforms

3. Problem adding to Berkeley DB file using DB_File

4. Berkeley::DB, File exists problem on solaris 2.7

5. Berkeley DB file interface, bug report

6. problems building BerkleyDB.pm for Berkeley DB 3.0.55

7. problem with Perl & Berkeley DB

8. fixes for file size limits with DB_File/Berkeley DB

9. db-3.0.55 and Berkeley-0.10 installation problems

10. Perl 5.005_002 and berkeley db problems

11. Berkeley DB problems

12. Assistance request for Berkeley DB / DB_FIle problem

 

 
Powered by phpBB® Forum Software