[ZODB-Dev] Webkit Threading and ZODB 3.3a2: problems on Windows

Shane Hathaway shane at zope.com
Thu Feb 19 13:48:48 EST 2004


On Wed, 18 Feb 2004, Matt Feifarek wrote:

> The crucial subtlety is that a thread does NOT destroy/garbage-collect 
> its servlet instance after servicing the request. Rather, the servlet 
> instance is "put to sleep" and kept around in case another request is 
> for the same servlet. If the application is taking requests for many 
> different servlets, the servlet instances do slip in and out of the pool 
> as different requests come in, but there is no guarantee that a servlet 
> instance will be brand new with every request.

It sounds like a servlet can re-awaken in a different thread from the one
in which it was put to sleep.  If that happens, changes made before
sleeping get registered with a different transaction than the transaction
being committed.  The new transaction is unaware of the change.  Later, 
you might accidentally commit or abort the original transaction.  What a 
mess!

If the above guess is correct, you would benefit from the experimental
support for binding transactions to connections (like Kapil mentioned.)  
Your servlets span threads; therefore, transactions should be bound to
connections rather than threads.

The API is still experimental because connection-bound transactions really
ought to be set up at the time you open the database, not when you open
the connection.  The API is simple enough that we haven't had a strong
reason to fix it, though.

Shane



More information about the ZODB-Dev mailing list