[ZODB-Dev] Shared/DC/ZRDB/TM.py:_register

Andreas Jung lists at zopyx.com
Tue May 13 04:44:15 EDT 2008



--On 13. Mai 2008 10:36:48 +0200 Vincent Pelletier <vincent at nexedi.com> 
wrote:

> Hi.
>
> _register method of TM class in Shared/DC/ZRDB/TM.py hides all exceptions.
>
> This makes descendants of this class prone to get stuck in a "registered"
> state withtout any possibility of them to get commited.
>
> To reproduce the problem:
>  - create a class inheriting from TM, and define a method calling
> register.    Add logs to abort and commit method to track transaction end.
>  - create a default error page which triggers a call to the method created
>    above. (this is equivalent to accessing some database from the error
> page,    for example)
>    Call it twice.
>    Most realistic case is using an instance surviving the transaction (a
>    global, or a persistant object)
>  - tigger an error in TPC (a raise in vote is the most realistic case)
> and get    the error page to render. The most obvious breakage I could
> see is when    trying to undo an non-undoable transaction (modify a
> script twice, undo the    oldest without undoing the newest)
>
> Here is what happens:
>  - first transaction (the "undo" in my example) raises in TPC,
> transaction is    marked as failed
>  - error message gets rendered in the same transaction (that's a
> ZPublisher    bug, but I think the problem "root" is hiding the failure)
>  - error message tries to register itself to transaction manager:
>    First try gets an exception (hidden in TM._register), but in the
> process    transaction's "_adapters" dict was modified. TM subclass
> instance is not    marked as registered.
>    Second try, now there is no exception raised, because transaction's
> "join"    is not called (because of _adapters content). Now the TM
> subclass instance    is marked as registered, but unknown to transaction
> (_adapters will not be    used to commit).
>
> The variant with just one call to TM._register "only" causes the instance
> to  be commited at next transaction using it.
>
> Is there any reason why TM._register is hiding exceptions ?

Isn't the right approach for integrating a module with ZODB transactions 
using a ZODB DataManager?

Andreas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zodb-dev/attachments/20080513/b635878c/attachment-0001.bin


More information about the ZODB-Dev mailing list