liveBook · Manning

Atomicity

As explained in Think Distributed Systems

Failure atomicity is the property that an operation either completes as an indivisible unit or exposes no partial effect when execution fails.

Atomicity means that an operation is observed as completing completely or not taking effect at all. It prevents failures from exposing a misleading partial result. section 5.3 section 11.1

A useful mental model treats a process as a sequence of atomic actions. A single action may be failure-atomic, but failure atomicity does not automatically compose across multiple actions: a crash can stop execution after a prefix. section 1.8 section 11.2.2

A payment and account-creation failure

Suppose signup charges a user's credit card and then creates an account. If execution crashes between those actions, the user is charged without receiving access. Atomicity requires the outcome to be observably equivalent to both actions completing or neither action taking effect. section 11.1

Atomicity has two related forms. Concurrency atomicity hides intermediary states from other processes; failure atomicity makes an interrupted operation appear to have happened completely or not at all. Failure atomicity is often needed to move from one correct state to another without exposing an incorrect intermediary. section 11.1

For a transaction, atomicity is represented by exactly one commit or abort. On one resource manager, local state can provide the guarantee; across multiple resource managers, an atomic commit protocol makes all subtransactions commit or all abort. section 5.3 section 6.1

A correct distributed atomic commit protocol provides two guarantees:

  • Safety prevents conflicting decisions: no participants commit while others abort. section 6.1.2
  • Liveness requires every participant eventually to settle permanently on commit or abort. section 6.1.2
Listing 6.1 Money transfer on one RM executing in one transaction
BEGIN
  UPDATE accounts SET balance = balance - $1 WHERE id = $2;
  UPDATE accounts SET balance = balance + $1 WHERE id = $3;
COMMIT

Use the two-update money transfer to see atomicity on one resource manager: both balance changes belong to one transaction and one commit decision. section 6.1

How Think Distributed Systems covers it

How deep it goes
Defines all-or-nothing behavior, models crash prefixes, distinguishes concurrency from failure atomicity, and specifies distributed safety and liveness.
Examples
Uses signup payment, one-resource money transfer, two-resource money transfer, and process traces that crash after zero or more steps.
What it assumes
Introduces process steps, executions, crashes, transactions, and distributed components while assuming familiarity with basic operations and system states.
What you can do after
Evaluate whether operations expose partial effects and reason about commit or abort guarantees under crashes and distributed coordination.
How it connects
Connects atomicity with transactions, ACID, isolation, consistency, durability, race conditions, serializability, and atomic commit protocols.

Also explained in

Compare how 13 books explain atomicity →

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.