Bookmarks

ACID — ACID transaction properties

Atomicity, Consistency, Isolation, Durability

A set of database transaction properties — atomicity, consistency, isolation and durability — that makes data changes predictable in the event of failures.

Also: ACID transactions, atomicity, consistency, isolation, durability

checked 8 Nov

All terms

ACID properties describe the guarantees a transaction provides — a group of data operations that runs as a single unit. The classic example is moving money from one account to another: it consists of a debit and a credit, and one half must never go through while the other disappears in a failure.

What ACID stands for

The acronym ACID was coined by Theo Härder and Andreas Reuter in their 1983 paper on database recovery, Principles of Transaction-Oriented Database Recovery.

PropertyWhat it guarantees
Atomicitythe transaction runs in full or not at all: on failure, all changes are rolled back
Consistencya transaction moves data from one valid state to another: integrity constraints and domain rules are not violated
Isolationconcurrent transactions do not see each other’s intermediate state; the result is as if they ran one after another
Durabilityonce a transaction is committed, its changes survive even a power cut: they are already written to the log

Isolation levels

Full isolation is expensive: concurrent transactions either block each other’s data or roll back because of conflicts. The SQL standard therefore defines four isolation levels — a compromise between strictness and speed.

LevelPossible anomalies
Read Uncommitteddirty reads, non-repeatable reads, phantom reads
Read Committednon-repeatable reads, phantom reads
Repeatable Readphantom reads
Serializableno anomalies

A dirty read means uncommitted data from another transaction is visible; a non-repeatable read means a repeated query within the same transaction returns a different result; a phantom read means a repeated query returns rows that were not present in the first read. Real databases are often stricter than the standard: in PostgreSQL, Read Uncommitted behaves like Read Committed, and phantoms already disappear at Repeatable Read. The default is Read Committed; the strictest level, Serializable, rules out all anomalies but conflicts more often and rolls transactions back.

When ACID is relaxed

ACID guarantees are hard to deliver in distributed systems: they require coordination between nodes that cannot survive a network partition. That is why many stores promise the weaker BASE model — eventual consistency — although some NoSQL systems do provide true ACID transactions across multiple records. For business operations spanning several services, the transaction is replaced with a saga or the transactional outbox pattern.

Sources

the term is written from these pages

Verified 8 Nov

Not to be confused with

what it is mixed up with and how it differs

  • CAP theorem

    CAP describes the limits of a distributed system under a network partition, while ACID describes the guarantees of a single transaction in a database.

  • eventual consistency

    Systems with eventual consistency relax ACID: they allow temporary divergence between replicas instead of strict guarantees.

In depth in the references

where the topic is covered in detail