Overview
ACID is what a database transaction promises. Atomicity: every statement commits or none does. Consistency: constraints hold before and after. Isolation: concurrent transactions do not see each other’s intermediate state, to a degree set by the transaction-isolation level. Durability: a committed write survives a crash because the write-ahead-log is flushed first. Wrap any write that spans more than one row or table in a single transaction instead of chaining autocommit statements.
Rules
- Use ACID for ledgers, inventory, and account state. Relax it only where brief staleness is harmless (base).
- ACID covers the primary’s committed state, not replica reads; see replication-lag.
- “Consistency” here means constraint validity. It is not the CAP-theorem consistency of distributed systems.
- Durability depends on settings: PostgreSQL with
synchronous_commit = offcan lose the most recent commits in a crash, without corrupting data.
Related
- postgres: transaction patterns and MVCC.
- transaction-isolation: the “I” in ACID.
- write-ahead-log: how durability is implemented.
- base: the model that trades ACID for availability.
- deadlock: how two transactions block each other.