knowmad has asked for the wisdom of the Perl Monks concerning the following question:
I've been wrangling with BerkeleyDB today trying to get a grip on how to do concurrent access with this database in order to provide a web interface to a legacy database. I am using BerkeleyDB.pm v0.25 with BerkeleyDB v4.2.
I'm using the DB_INIT_CDB and DB_INIT_MPOOL flags to Initialize locking for the Berkeley DB Concurrent Data Store. I found an example on the web from Paul M. who wrote BerkeleyDB which shows how to request a write lock. So far, so good.
My problem comes when I want to use this lock. There is not much in the BerkeleyDB.pm pod that explains using the DB_WRITECURSOR flag so I have resorted to the docs at sleepycat.com(1).
To my tired eyes, it seems that these docs are saying that I need to use a cursor to get a write lock. OK, but once I open a cursor, the docs say that I should not call db_put. OK, so let's try c_put. Unfortunately, that only appears to overwrite or duplicate the record under the cursor. I want to insert a new record. I do not see any flag available for doing that.
Could someone familiar with concurrency in BerkeleyDB please shed some light on this issue for me? Some example code would be excellent!
Update: I finally figured out the proper incantantation of flags needed to get BerkeleyDB to operate safely in a multi-process environment. See node #330510 "Testing DB concurrency with BerkeleyDB" for more details.
Many Thanks,
William
(1) Berkeley DB Concurrent Data Store applications
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Concurrent access with BerkeleyDB
by no_slogan (Deacon) on Feb 20, 2004 at 06:21 UTC | |
by knowmad (Monk) on Feb 20, 2004 at 09:44 UTC |