[ZODB-Dev] snapshot isolation how-to
Shane Hathaway
shane@zope.com
Wed Apr 16 16:03:37 EDT 2003
Jeremy Hylton wrote:
> On Tue, 2003-04-15 at 16:43, Shane Hathaway wrote:
>
>>It's an experimental feature. It binds transactions to the connection
>>rather than the thread, allowing you to run multiple transactions in a
>>single thread. Use of setLocalTransaction() is not generally compatible
>>with Zope.
>
>
> I was wondering, though, how a local transaction becomes unset. I think
> we need to flesh out the interface a bit more. It looks like a
> connection that calls setLocalTransaction() can only participate in one
> transaction. I don't see any code that clears _transaction when it
> commits.
The connection reuses the same Transaction object for further transactions.
> I'm also not clear on what happens when a Connection calls
> getTransaction() before setLocalTransaction(). It looks like the
> Connection will get hooked up to two transactions.
Yes, that's why the application should call setLocalTransaction() as
soon as it has the connection object. A connection can operate in
either mode but not both.
Here's another possible way to do this. Maybe the DB.open() method
should accept an optional "local_transactions" boolean argument. That
way, there's no chance to switch modes too late, and the connection will
never wind up in multiple transactions (hopefully.)
Shane
More information about the ZODB-Dev
mailing list