[ZODB-Dev] [Persistent] STICKY mechanism unsafe

Jim Fulton jim at zope.com
Mon Aug 20 10:45:14 EDT 2007


On Aug 20, 2007, at 2:25 AM, Christian Theune wrote:

> Hi,
>
> just for my understanding: we don't get bitten by this because Zope  
> uses
> the ThreadTransactionManager which keeps objects within one thread (at
> one time)?

Dieter appears to have been bitten by this and he is one of we. :)

We, and I presume he, can be bitten by a Python function called from  
BTree code calling back into the code on the same object.  This is  
possible, for example, in a __cmp__ or related method.  I assume that  
this is what happened to Dieter.  Obviously, this would be a fairly  
"special" comparison method.

In general though, you are right that the ZODB is designed to support  
a threading model in which multiple threads run single-threaded code  
in multiple isolated threads.

It's worth noting that there are indirect ways that objects can be  
called from multiple threads:

- Object deactivation.  Until recently (3.8), objects could be  
deactivated from other threads while they were in use by n  
application threads.

- __del__ methods or weakref callbacks can cause calls to persistent  
objects from other (non-application) threads.

Jim

--
Jim Fulton			mailto:jim at zope.com		Python Powered!
CTO 				(540) 361-1714			http://www.python.org
Zope Corporation	http://www.zope.com		http://www.zope.org





More information about the ZODB-Dev mailing list