[ZODB-Dev] API for dooming a transaction for ZODB 3.3

Jeremy Hylton jeremy at zope.com
Mon Jan 12 10:57:58 EST 2004


On Thu, 2004-01-08 at 09:18, Steve Alexander wrote:
> I'd like to add some sort of API for dooming a transaction to ZODB 3.3.
> 
> Dooming a transaction is a way of ensuring that a transaction will not 
> successfully commit, without actually aborting the transaction immediately.

If a transaction is going to fail, it seems desirable to make it fail
fast.  I don't think there's any benefit from continuing doomed work.

> This is particularly useful in Zope applications when an error occurs in 
> an application, and you want to ensure the transaction will not be 
> committed, but you don't want to present the exception to the user.

I'm having trouble convincing myself that this should be a feature of
Transaction objects.  The idea could be implemented like undo, abort
version, and commit version:  Implement a simple data manager that
performs the desired behavior during 2PC.  

Does the problem stem from the indirect connection between ZODB and
the Zope publisher?  As Dieter said, an exception seems like the
clearest way to indicate a failure to the publisher.  The worry, then,
is that buggy code on the call stack will catch the exception by
mistake and hide it from the publisher.  If that's the case, one
solution might be to have a method on the publisher that indicates a
failure.

Perhaps the problem is that there needs to be more coordination that
get_transaction() provides.  That is, if some code calls abort() or
commit(), then future calls to get_transaction() returns a new
transaction object.  One possible solution there is to distinguish
between getting the current transaction and getting a new
transaction -- for example, get_transaction() vs. new_transaction();
if you call get_transaction(), you get the current transaction, in
progress, aborted, or committed.  Then you wouldn't have later code
accidentally starting a new transaction, although you could still have
the problem with code that intentionally created a new transaction.

Do you have any other ideas about the name?  Doom strikes me as too
cute.

Jeremy





More information about the ZODB-Dev mailing list