[Dbix-class] transactions, etc.

Brandon Black blblack at gmail.com
Wed Jan 24 16:26:08 GMT 2007


On 1/24/07, Josef Karthauser <joe at tao.org.uk> wrote:
> Hi Matt,
>
> Thoughts about transactions if I may.
>
> Firstly things look a bit gnarly with respect to auto re-connection,
> and forking (validate_pid).  It doesn't look as if any transaction
> rules are in place for these operations, which means that things
> can get out of sync.  If the database connection really needs to
> be reopened then a check ought to be made to see if the application
> thinks that a transaction is currently in process.  If it does then
> it needs to be delivered a signal probably, as at that point all
> bets are off.  Same also if the process has forked, although that
> case looks like it might be dealt with automatically if the first
> case is resolved.
>

The current development branch has re-worked this, I think your
comments are based on the released 0.07 stuff.  In the dev branch, the
recommended txn_do style handles reconnects correctly, but I don't
think manually using txn_begin/txn_end offer explicit guarantees in
some corner cases (like, if you started a transaction, did a few
things successfully, then lost your connection in mid-transaction -
but that would be rare assuming you're not holding transactions open
for long periods, which you shouldn't - but in any case what will
happen is you'd lose the top half of the transaction, but carry on
trying to execute the rest of it (and probably fail there for
referential integrity reasons in many cases)).

-- Brandon



More information about the Dbix-class mailing list