On Wed, 09 Mar 2005 15:34:24 -0800, Dean Arnold <[EMAIL PROTECTED]> wrote:
> Dan Scott wrote:
> > On Wed, 9 Mar 2005 13:29:40 -0800, Darren Duncan
> > <[EMAIL PROTECTED]> wrote:
> >
> >>At 8:55 AM +0000 3/9/05, Martin J. Evans wrote:
> >>
> >>>Just a small point.
> >>>I could be wrong (I cannot look it up right now) but I think in ODBC
> >>>SQLEndTran
> >>>can issue a rollback or commit on ALL connections. 
> >
> > Can someone provide a scenario where you would want to issue a global
> > rollback or commit?
> >
> > Perhaps (probably) I'm suffering from a limited imagination here, but
> > it seems like you would want to rollback or commit on a connection by
> > connection basis.

> 2PC. But DBI doesn't support that (yet).

There's a bit more to 2PC than just that, unfortunately.  In
particular, the participant transactions have to be told by the
coordinate that a commit is imminent, so they can indicate whether
they can commit.  (It's easy if they can't; they roll back and say
"can't commit".)  Assuming they can commit, they log a record
indicating that they're in a state where they can commit or rollback -
and the transaction will not then be rolled back by accident until the
coordinator has issued a decision.  When the coordinator records its
decision, it broadcasts that to the participants, who then act
accordingly.  If a participant crashes between the time when it
indicates that it can commit and it gets a decision from the
coordinator, it contacts the coordinator after recovering (and
reclaiming all the locks it held) and decides whether to commit or
rollback.  There are some wrinkles here (presumed commit, presumed
abort, etc) and complications (heuristic rollback when a commit should
have occurred), but the key point which a naive implementation based
an raw non-2PC transaction support is the recovery in crash scenarios
- which is critical.

-- 
Jonathan Leffler <[EMAIL PROTECTED]>  #include <disclaimer.h>
Guardian of DBD::Informix - v2003.04 - http://dbi.perl.org
"I don't suffer from insanity - I enjoy every minute of it."

Reply via email to