[pybsddb] Random "key not found"?

David Wolever wolever at cs.toronto.edu
Thu Aug 21 17:57:12 CEST 2008

I've been doing some load testing on my application, and I've noticed  
that, from time to time, "DB.get(...)" will return "key not found",  
even though the key is there and previous/subsequent gets() succeed.

I've been able to reproduce the problem with a simple script (or, at  
least, as simple as a threaded script can be), which I've attached.

This is what should happen after a couple tries:
Exception in thread 25578496:
Traceback (most recent call last):
   File "bsddb_problem.py", line 57, in child
     raise Exception("Error getting key %s: %s" %(id, e))
Exception: Error getting key 60: (-30988, 'DB_NOTFOUND: No matching  
key/data pair found')

By turning on debugging you can see that previous gets on the key (in  
this case, '60') have succeeded, and if something like "db.get(id)"  
is added in the exception handler, the correct value is retrieved.

So, my questions:
- Am I doing anything really stupid?
- Is there any way to get around it? I've tried using cursors, and  
that _seems_ to work, but I don't entirely understand why, so I'm a  
little wary.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: bsddb_problem.py
Type: text/x-python-script
Size: 2121 bytes
Desc: not available
URL: <https://mailman.jcea.es/pipermail/pybsddb/attachments/20080821/de615b8d/attachment.bin>

More information about the pybsddb mailing list