Documentation

CslibFrontier.Computability.Distributed.AtomicCommit.TwoPhaseCommit

Distributed Atomic Commitment and Fail-Stop Two-Phase Commit Step #

This module specifies the distributed Atomic Commitment problem (AC1 Uniform Agreement across all deciding processes including crashed ones, AC2 Abort Validity on any no vote, and AC3 failure-free Commit Nontriviality) and proves an intermediate fail-stop register-state Two-Phase Commit (2PC) step toward [Gra78], §5.8.3.3.2 (pp. 466–469), [Ske81], §§1–3 (pp. 134–137), and [SS83], §§II–IV (pp. 220–223), not the cited crash-recovery log-replay endpoint (#7289).

In this fail-stop 2PC step, a designated coordinator coord : P sends vote requests to all cohort sites r ≠ coord in Phase 1. Each cohort casts its initial Vote (yes moving to .uncertain, or no unilaterally deciding .aborted) and replies to coord. In Phase 2, coord decides .committed and broadcasts .commit only if votes coord = .yes and every cohort replied .yes; if votes coord = .no, any cohort replied .no, or a site crashed (timeout), coord decides .aborted and broadcasts .abort. Stable undo/redo log forces ([Gra78], §5.8.3.3.2, p. 468) are abstracted as persistent per-site TwoPCLocalState registers retained across permanent fail-stop crashes rather than crash-recovery log-replay restarts (#7289).

Within this fail-stop model we prove two complementary step families:

  1. Fail-stop safety and fault-free completion: Across arbitrary fail-stop crashes and message omissions, decisions are write-once (twoPC_decision_stable_failStop) and every reachable configuration satisfies UniformAgreement (twoPC_agreement_failStop, AC1) and AbortValidity (twoPC_abort_of_vote_no_failStop, AC2). When no faults occur and all processes vote yes, 2PC reaches unanimous .commit (twoPC_failureFree_commit_failStop, AC3); when any process votes no, a fault-free run reaches unanimous .abort (twoPC_failureFree_abort_failStop).
  2. Survivor uncertainty on coordinator crash (2 ≤ Fintype.card P): Whenever at least two processes participate, there exist two reachable crash/omission configurations sAbort and sCommit with the same surviving operational cohort {q} (q ≠ coord, votes q = .yes, local state .uncertain, empty survivor inbox) such that coord voted .no and already decided .abort in sAbort whereas coord already decided .commit in sCommit (twoPC_uncertain_bivalent_failStop; on three or more sites, cohort-vote ambiguity with votes coord = .yes also arises). Consequently, no termination rule depending only on the surviving processes' states, votes, and inbox can safely decide for q without violating UniformAgreement (twoPC_no_safe_survivor_termination_failStop).

Main definitions #

Main results #

References #

Atomic commitment specification #

Initial vote of a site on whether it is prepared to commit or unilaterally aborts.

Instances For

    Irreversible transaction outcome decided by a site.

    Instances For

      Uniform Agreement (AC1): any two sites (operational or crashed) that have reached decisions agree on the same Decision.

      Instances For
        def Cslib.Distributed.AtomicCommit.AbortValidity {P : Type u_1} (votes : P → Vote) (dec : P → Option Decision) :

        Abort Validity (AC2): if any site initially voted .no, no site ever decides .commit.

        Instances For

          Every site in P has reached decision d.

          Instances For

            Every operational site in alive has reached decision d.

            Instances For
              @[instance_reducible]

              Finite-process decidability of UniformAgreement.

              @[instance_reducible]
              instance Cslib.Distributed.AtomicCommit.instDecidableAbortValidity {P : Type u_1} [Fintype P] (votes : P → Vote) (dec : P → Option Decision) :

              Finite-process decidability of AbortValidity.

              @[instance_reducible]

              Finite-process decidability of AllDecided.

              @[instance_reducible]

              Decidability of OperationalDecided over alive : Finset P.

              theorem Cslib.Distributed.AtomicCommit.AbortValidity.eq_abort_of_eq_some {P : Type u_1} {votes : P → Vote} {dec : P → Option Decision} (hval : AbortValidity votes dec) (hno : ∃ (p : P), votes p = Vote.no) {q : P} {d : Decision} (hq : dec q = some d) :

              Under AbortValidity, if at least one site voted .no, any decided outcome is .abort.

              Fail-stop register-state Two-Phase Commit (2PC) step #

              Local automaton states of centralized Two-Phase Commit ([Ske81], Figure 2, p. 135; [Gra78], §5.8.3.3.2, p. 468).

              • init : TwoPCLocalState

                Initial state (q_i) prior to Phase 1 voting or request broadcast.

              • waitVotes : TwoPCLocalState

                Coordinator Phase 1 state (w_1) awaiting cohort vote replies.

              • uncertain : TwoPCLocalState

                Cohort Phase 1 state (w_i) after voting .yes and forcing undo/redo logs, awaiting the coordinator's Phase 2 verdict.

              • committed : TwoPCLocalState

                Final committed state (c_i).

              • aborted : TwoPCLocalState

                Final aborted state (a_i).

              Instances For

                Point-to-point protocol messages of centralized 2PC.

                • voteRequest {P : Type u_1} (dest : P) : TwoPCMsg P

                  Phase 1 REQUEST_COMMIT sent by the coordinator to cohort dest.

                • voteReply {P : Type u_1} (src : P) (vote : Vote) : TwoPCMsg P

                  Phase 1 vote reply sent by cohort src to the coordinator.

                • verdict {P : Type u_1} (dest : P) (dec : Decision) : TwoPCMsg P

                  Phase 2 final verdict (COMMIT or ABORT) sent by the coordinator to cohort dest.

                Instances For
                  @[instance_reducible]

                  Recipient process of a TwoPCMsg given the designated coordinator coord.

                  Global configuration of centralized 2PC under fail-stop crashes and message omissions.

                  • localState : P → TwoPCLocalState

                    Local automaton state of each process (retained permanently even if the process crashes).

                  • yesVotes : Finset P

                    Set of cohorts from which the coordinator has received .yes replies.

                  • sawNo : Bool

                    Whether the coordinator has received at least one .no reply.

                  • alive : Finset P

                    Currently operational (non-crashed) processes.

                  • msgs : Multiset (TwoPCMsg P)

                    Multiset of in-flight messages on the asynchronous network.

                  Decision vector of a global TwoPCState across all sites (operational or crashed).

                  Initial global configuration of 2PC: all processes operational in .init with empty network.

                  Transition labels of the 2PC operational LTS.

                  Instances For
                    @[instance_reducible]

                    Whether a TwoPCAction is a normal message-passing step without crashes or message drops.

                    def Cslib.Distributed.AtomicCommit.twoPCStep? {P : Type u_1} [DecidableEq P] [Fintype P] (coord : P) (votes : P → Vote) (s : TwoPCState P) (act : TwoPCAction P) :

                    Partial transition function of centralized 2PC for designated coordinator coord and initial vote profile votes.

                    def Cslib.Distributed.AtomicCommit.twoPCLts {P : Type u_1} [DecidableEq P] [Fintype P] (coord : P) (votes : P → Vote) :

                    Operational Cslib.LTS of the fail-stop register-state 2PC step with crashes and message omissions (after [Gra78], §5.8.3.3.2, pp. 466–469).

                    def Cslib.Distributed.AtomicCommit.TwoPCReachable {P : Type u_1} [DecidableEq P] [Fintype P] (coord : P) (votes : P → Vote) (s : TwoPCState P) :

                    Reachability of a 2PC configuration from twoPCStart P in the fail-stop register-state step.

                    Fail-stop safety (AC1 and AC2) and decision stability of 2PC #

                    theorem Cslib.Distributed.AtomicCommit.twoPC_decision_stable_failStop {P : Type u_1} [DecidableEq P] [Fintype P] {coord : P} {votes : P → Vote} {s s' : TwoPCState P} (hreach : (twoPCLts coord votes).CanReach s s') {p : P} {d : Decision} (hd : s.decision p = some d) :
                    s'.decision p = some d

                    Fail-stop register-state step toward [Gra78], §5.8.3.3.2 (p. 468), not the cited crash-recovery log-replay result (#7289): once a site decides .commit or .abort in twoPCLts, its decision is preserved along all subsequent transitions (including fail-stop crashes and message drops).

                    theorem Cslib.Distributed.AtomicCommit.twoPC_agreement_failStop {P : Type u_1} [DecidableEq P] [Fintype P] {coord : P} {votes : P → Vote} {s : TwoPCState P} (hreach : TwoPCReachable coord votes s) :

                    Fail-stop register-state step toward [Gra78], §5.8.3.3.2 (p. 469) and [Ske81], §2 (p. 136), not the cited crash-recovery log-replay result (#7289): in every reachable configuration of twoPCLts (across arbitrary fail-stop site crashes and message omissions), all decided sites—operational or crashed—satisfy UniformAgreement (AC1).

                    theorem Cslib.Distributed.AtomicCommit.twoPC_abort_of_vote_no_failStop {P : Type u_1} [DecidableEq P] [Fintype P] {coord : P} {votes : P → Vote} {s : TwoPCState P} (hreach : TwoPCReachable coord votes s) :

                    Fail-stop register-state step toward [Gra78], §5.8.3.3.2 (p. 468) and [Ske81], §2 (p. 136), not the cited crash-recovery log-replay result (#7289): if any site voted .no, no site decides .commit in any reachable configuration of twoPCLts (AC2).

                    Failure-free execution (AC3 and abort completion) #

                    theorem Cslib.Distributed.AtomicCommit.twoPC_failureFree_commit_failStop {P : Type u_1} [DecidableEq P] [Fintype P] {votes : P → Vote} (coord : P) (hyes : ∀ (p : P), votes p = Vote.yes) :
                    ∃ (tr : List (TwoPCAction P)) (s : TwoPCState P), (∀ a ∈ tr, a.isFaultFree = true) ∧ (twoPCLts coord votes).MTr (twoPCStart P) tr s ∧ AllDecided s.decision Decision.commit ∧ s.alive = Finset.univ ∧ s.msgs = 0

                    Fail-stop register-state step toward [Gra78], §5.8.3.3.2 (pp. 467–468), not the cited crash-recovery log-replay result (#7289): when all sites vote .yes, twoPCLts admits a crash-free, omission-free execution from twoPCStart P reaching AllDecided s.decision .commit with all sites operational and an empty network (AC3).

                    theorem Cslib.Distributed.AtomicCommit.twoPC_failureFree_abort_failStop {P : Type u_1} [DecidableEq P] [Fintype P] {votes : P → Vote} (coord : P) (hno : ∃ (p : P), votes p = Vote.no) :
                    ∃ (tr : List (TwoPCAction P)) (s : TwoPCState P), (∀ a ∈ tr, a.isFaultFree = true) ∧ (twoPCLts coord votes).MTr (twoPCStart P) tr s ∧ AllDecided s.decision Decision.abort ∧ s.alive = Finset.univ

                    Fail-stop register-state step toward [Gra78], §5.8.3.3.2 (pp. 467–468), not the cited crash-recovery log-replay result (#7289): when at least one site votes .no, twoPCLts admits a crash-free, omission-free execution from twoPCStart P reaching AllDecided s.decision .abort.

                    Coordinator-crash uncertainty and inherent blocking of 2PC #

                    Projection of a 2PC global configuration visible to the surviving operational processes: the operational survivor set alive, each survivor's local state (masked to .init outside alive), each survivor's initial vote (masked to .yes outside alive), and all in-flight messages addressed to survivors.

                    • alive : Finset P

                      Currently operational sites.

                    • survivorState : P → TwoPCLocalState

                      Local states of operational sites (.init outside alive).

                    • survivorVote : P → Vote

                      Initial votes of operational sites (.yes outside alive).

                    • inbox : Multiset (TwoPCMsg P)

                      In-flight messages addressed to operational sites.

                    Extract the survivor-visible projection of a 2PC configuration s.

                    theorem Cslib.Distributed.AtomicCommit.twoPC_uncertain_bivalent_failStop {P : Type u_1} [DecidableEq P] [Fintype P] (hcard : 2 ≤ Fintype.card P) (coord : P) :
                    ∃ (q : P) (votesAbort : P → Vote) (sAbort : TwoPCState P) (sCommit : TwoPCState P), q ≠ coord ∧ votesAbort coord = Vote.no ∧ votesAbort q = Vote.yes ∧ TwoPCReachable coord votesAbort sAbort ∧ TwoPCReachable coord (fun (x : P) => Vote.yes) sCommit ∧ sAbort.alive = {q} ∧ sAbort.localState q = TwoPCLocalState.uncertain ∧ sAbort.msgs = 0 ∧ sAbort.decision coord = some Decision.abort ∧ sCommit.decision coord = some Decision.commit ∧ TwoPCState.survivorView coord votesAbort sAbort = TwoPCState.survivorView coord (fun (x : P) => Vote.yes) sCommit

                    Fail-stop register-state step toward [Ske81], §1 (p. 134) and [SS83], §IV-C, Lemma 1 (p. 223), not the cited crash-recovery result (#7289): for 2 ≤ Fintype.card P and any coordinator coord : P, there exist a surviving cohort q ≠ coord, vote profile votesAbort (votesAbort coord = .no, votesAbort q = .yes), and twoPCLts-reachable configurations sAbort and sCommit such that:

                    1. in both configurations q is the sole operational survivor (alive = {q}), is .uncertain, and has an empty network (msgs = 0),
                    2. sAbort and sCommit induce the exact same TwoPCSurvivorView,
                    3. coord has already decided .abort in sAbort whereas coord has already decided .commit in sCommit.
                    theorem Cslib.Distributed.AtomicCommit.twoPC_no_safe_survivor_termination_failStop {P : Type u_1} [DecidableEq P] [Fintype P] (hcard : 2 ≤ Fintype.card P) (coord : P) (term : TwoPCSurvivorView P → Decision) :
                    ∃ (votes : P → Vote) (s : TwoPCState P), TwoPCReachable coord votes s ∧ s.alive.Nonempty ∧ ¬UniformAgreement fun (p : P) => match s.decision p with | some d => some d | none => if p ∈ s.alive then some (term (TwoPCState.survivorView coord votes s)) else none

                    Fail-stop register-state step toward [Gra78], §5.8.3.3.2 (p. 469), [Ske81], §1 (p. 134), and [SS83], §IV-C, Lemma 1 (p. 223), not the cited crash-recovery result (#7289): for 2 ≤ Fintype.card P, no termination rule term depending only on the surviving processes' TwoPCSurvivorView can assign decisions to undecided survivors in a way that preserves UniformAgreement across all reachable configurations of twoPCLts.