liveBook · Manning

Distributed transaction

As explained in Think Distributed Systems

A distributed transaction is a transaction whose participants are located across multiple components or stores and must reach a coordinated commit-or-abort outcome.

A distributed transaction coordinates changes across two or more systems, often called resource managers. It must produce one unanimous outcome: every participant commits, or every participant aborts. section 6.0 section 6.4

Think of it as several local transactions joined into one global transaction. Each participant owns private local state, while messages coordinate the participants over the network. A participant may be working, prepared, committed, or aborted; committed and aborted are final states. section 6.1 section 6.2

Transferring money between two stores

One participant subtracts money from an account, while another adds it to a different account. Independent local commits could leave only one change applied. A distributed transaction coordinates both operations so the transfer commits together or aborts together. section 6.1

Judge a distributed transaction by two complementary guarantees:

  • Safety prevents conflicting decisions, such as one participant committing while another aborts. section 1.4.1
  • Liveness requires every participant eventually to reach a decision, preventing the transaction from remaining stuck. section 1.4.1
  • Atomic commit protocols coordinate these guarantees across resource managers. Two-Phase Commit is the best-known protocol: it separates Prepare from Commit, guaranteeing safety and liveness for resource-manager failure but only safety for transaction-coordinator failure. section 6.4
Figure 6.3 A distributed transaction consists of two or more nondistributed transactions.
A diagram of a non-distributed transaction

AI-generated content may be incorrect.

Use the decomposition diagram to connect one global transaction with its component local transactions. section 6.2

How Think Distributed Systems covers it

How deep it goes
Explains local and global states, safety, liveness, and atomic commit protocols, while focusing on atomicity rather than other ACID guarantees.
Examples
Uses a two-store money transfer, two key-value-store participants, transaction states, and a two-phase commit sequence.
What it assumes
Assumes a model of concurrent components, private local state, network messages, and discrete steps.
What you can do after
Evaluate distributed transaction correctness by checking unanimous decisions for safety and eventual decisions for liveness.
How it connects
Connects atomicity with resource managers, local transactions, safety, liveness, atomic commitment, and Two-Phase Commit.

Also explained in

Compare how 4 books explain distributed transaction →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Think Distributed Systems. The section links point to the parts of the book it draws on.