Distributed transaction processing Acts as coordinator TMo Remote site by davebusters

VIEWS: 20 PAGES: 3

									                                                                             Two-phase commit state diagrams
         6.9 Distributed transaction processing
                                                                                   From
                             Acts as coordinator                                   client
                                                                                                       qo                        qi
                                                                                     commit-req                      vote-req           vote-req
                                                         TM1
                                                                                       vote-req                        yes                no
                            TMo
                                                                                                po           a            pi              ai
                                                        Remote site 1                                Any no o                   abort
User transaction starts                        Participants                          All yes         abort All done commit      done
                                                                                     commit                   --     done

              TM        Transaction manager                                                    co           fo            ci
                                                         TM2                                      All done
                                                                                                      --
                        Subtransaction
                                                                                               Coordinator S0             Participant Si
                                                         Remote site 2
24/07/2001                                                               1   24/07/2001                                                            2




         Notation                                                                  Requirements for atomic
      




              Initial states                                                       commit protocols
          ¡




                      q0.for coordinator                                       ¦




                                                                                     AC1: No contradictory commit/abort decisions.
                      qi for paticipant Si (ready to vote)
          ¡




                                                                               ¦




                                                                                     AC2: Participants cannot reverse vote.
     ¢




              Final states                                                     ¦




                                                                                     AC3: Can commit only if all voted Yes.
          ¡




                      c0: decision made to commit; ci: will commit             ¦




                                                                                     AC4: Must commit if no failure and all participants
                                                                                     voted Yes.
                      a0: decision made to abort; ai: will abort
          ¡




                                                                               ¦




                                                                                     AC5: If all failures are repaired and no new ones occur,
 £




              s        s’: I/O means
                                                                                     then all participants must eventually reach decision.
                  ¤




                      Input message I is received in state s.
          ¥




                                                                                                                          (transparency)
                      New state s’ is recorded in stable log.
          ¥




                      Output message O is sent out.
          ¥




24/07/2001                                                               3   24/07/2001                                                            4




                                                                                                                                                       1
           Recovery actions on time-out                                                Simple TP
    




            Coordinator                                                         




                                                                                       Participant Si sends “getState” request to
             ¡




                     In state p0: Assume No for no reply and move to                   coordinator S0;
                     a0.                                                                ¡




                                                                                         If c0.or a0 is returned, enter ci or ai respectively
    




            Participant                                                                 ¡




                                                                                                 If p0 is returned, stay in pi.
                     In state qi: Abort unilaterally (i.e., move to ai)
             ¡




                                                                                




                                                                                       Repeat on time-out.
                     In state pi: invoke Termination Protocol (e.g.,
             ¡




                     Simple TP).


                                                                                                 Simple TP blocks till coordinator recovers.

24/07/2001                                                                5   24/07/2001                                                                  6




                                                                                       Restart action on recovery
           Cooperative TP for participant site Si                                  ¤




                                                                                            Can recover independently if not failed in pi.
       ¢




             (1) Try Simple TP.                                                    ¤




                                                                                            If failed in pi, restart as if after long timeout interval.
       ¢




             (2) If coordinator doesn’t respond send                               ¤




                                                                                            Coordinator S0: check log for the last state.
             “getState” to other participants.                                               ¥




                                                                                                Done: do nothing.
                     Participant Sj is in aj or cj: Move to ai or ci.                           c0: broadcast “Commit”
                                                                                             ¥




                 £




                                                                                                Else: move to a0 and broadcast “Abort”.
                                                                                             ¥




                     None in aj or cj, but Sk is in qk: Move to ai.
                 £




                 £




                     Each Sj that responds is in pj: Reset timer and go
                                                                                   ¤




                                                                                            Participant Si: check log for last recorded state.
                                                                                                ci or ai: broadcast state to other participants.
                                                                                             ¥




                     back to step (1).
                                                                                                qi: move to ai and broadcast state.
                                                                                             ¥




                                                                                                pi: invoke Cooperative TP.
                                                                                             ¥




24/07/2001                                                                7   24/07/2001                                                                  8




                                                                                                                                                              2
       2PC in JavaSpace/Jini                                                 Committing in JavaSpace
    




        A client requests the TM (coordinator) to create                 ¤




                                                                              public interface TransactionParticipant
        trans_id. It then creates participants that join in the                £




                                                                                int prepare (mgr, trans_id) (=vote)
        transaction.
                                                                                void commit (mgr, trans_id);
                                                                               £




    




        package net.jini.core.transaction.server
                                                                                void abort (mgr, trans_id);
                                                                               £




    




        public interface TransactionManager {
           Created create (leaseFor);
         ¡




             ¢




              returns (trans_id, granted_Lease)
         £




           void join (trans_id, participant);                            ¤




                                                                              http://www.sun.com/jini/specs/
           int getState (trans_id);
         £




           void commit (trans_id);
         £




           void abort (trans_id);
         £




         }


24/07/2001                                                        9   24/07/2001                                        10




                                                                                                                             3

								
To top