bsddb3 locking questions

Eric S. Johansson esj at harvee.org
Sat Dec 31 10:29:37 EST 2005


are there any simple examples of how to do record locking with bsddb3?

the bsddb3 documentation is reasonably opaque.  For example, the DB 
initialization requires a DBEnv instance for certain environmental 
features such as locking.  but if you want locking, what happens next? 
I suspect the pattern goes something like the following but it's not 
clear from the documentation.

dbe = DBEnv.open()
(does the home directory need to be specified or is there a systemwide 
default?  Is this per application or does a common pool work?

dbe.set_lk_detect(...DB_LOCK_YOUNGEST)
(but what about db_deadlock??? do I need a cron job?)

dbe.lock_id()

dbi = db.DB()

dbi.open(..)
(does the filename specified here need to be the same directory as the 
homedir in DBEnv or can it in a totally separate location? any 
advantages to either?)

lock = dbe.get_lock()
dbi.get/put
dbe.lock_put(lock)

(the above pattern is for record locking but for database locking, the 
lock get and put calls would bracket the open/close call)


if you close the database, should you automatically close the env or (as 
I suspect) the database environment can cover one or more database 
specific incarnations but if you have access different databases, each 
one should have its own environment.

anything else I'm missing?

thanks for any guidance,
---eric




More information about the Python-list mailing list