liveBook · Manning

ACID

As explained in PostgreSQL Mistakes and How to Avoid Them

ACID is the set of atomicity, consistency, isolation, and durability properties that characterize reliable database transactions.

ACID describes atomicity, consistency, isolation, and durability—the properties expected from reliable database transactions. PostgreSQL can guarantee these properties within one server while an application still breaks them by spreading one logical operation across a primary and a lagging read replica. section 5.6

A stale replica breaks the business operation

An account balance is read as 100 on standby beta, changed to 90 on primary alpha, then read again as 100 on beta. The application applies a +50 bonus and stores 150, producing an incorrect result. The database remains ACID-safe per node; the application attempted an atomic transaction across two nodes without distributed transaction coordination. section 5.6

Two-Phase Commit can coordinate such work through PREPARE TRANSACTION and related commands, but prepared transactions should remain short-lived. Replication lag, locking, crashes, and abandoned prepared work make this approach operationally difficult and can eliminate the benefit of using a read replica. section 5.6

How PostgreSQL Mistakes and How to Avoid Them covers it

How deep it goes
Distinguishes per-node ACID safety from distributed transactions and outlines Two-Phase Commit without implementing its full protocol.
Examples
Uses a stale account balance, a mistaken bonus, primary alpha, and standby beta to demonstrate a cross-node consistency failure.
What you can do after
Diagnose/debug with it by separating database-level ACID guarantees from application-level coordination across replicated nodes.
How it connects
Connects ACID to database transactions, replication lag, read replicas, distributed transactions, and Two-Phase Commit.

Also explained in

Compare how 7 books explain ACID →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of PostgreSQL Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.