[pybsddb] Random "key not found"?

George Feinberg gmf at maine.rr.com
Thu Aug 21 19:11:11 CEST 2008


David,

Read/write concurrent applications need to either use transactions or  
the CDS
environment (multiple readers, single-writer) in order to protect state.

George

On Aug 21, 2008, at 11:57 AM, David Wolever wrote:

> Hey,
> 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.
>
> Thanks,
> David
>
>
> <bsddb_problem.py>_______________________________________________
> pybsddb mailing list
> pybsddb at argo.es
> http://mailman.argo.es/listinfo/pybsddb
> http://www.argo.es/~jcea/programacion/pybsddb.htm




More information about the pybsddb mailing list