Use it to reason about transaction guarantees and their trade-offs.
ACID Properties
ACID: Atomicity (all or nothing), Consistency (constraints hold), Isolation (concurrent transactions don't interfere beyond the chosen level), Durability (committed data survives crashes).
1. Durability settings: SHOW synchronous_commit; / SHOW VARIABLES LIKE 'innodb_flush_log_at_trx_commit';.
2. Isolation level of sessions.
3. Constraints defined.
4. Application uses transactions where needed.
5. Test crash recovery in lab.
transaction → atomic commit → constraints checked → isolated reads → flushed to durable storage
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 How to verify Verify boundary
Read the durability settings on the live server. Confirm the application uses explicit transactions for multi-statement changes. Check the storage layer honours fsync (no unsafe write caches).
Step 2 Common failures Narrow the fault
Relaxed durability (for example synchronous_commit=off) can lose the last commits on crash. Autocommit mode makes each statement its own transaction, so a failure halfway leaves partial changes. Non-transactional tables ignore ROLLBACK.
Durability depends on settings like fsync, synchronous_commit, innodb_flush_log_at_trx_commit — disabling them trades safety for speed. Isolation level decides which anomalies are possible.
SHOW synchronous_commit;— first check for this topicpsql -c "SELECT now(), version();"— PostgreSQL reachable and versionmysql -e "SELECT NOW(), VERSION();"— MariaDB/MySQL reachable and versionsqlcmd -S <server> -Q "SELECT @@VERSION"— SQL Server reachable and version
ReferenceWhat it is1 section · depth on demand
How it works
Databases write changes to a write-ahead log before changing data files. On COMMIT the log is flushed to disk; after a crash the server replays the log to redo committed work and undo the rest. Isolation is provided by locks, MVCC snapshots or both.
ReferenceImportant terms & boundaries3 sections · depth on demand
ACID in practice
| Property | Meaning | Mechanism |
|---|---|---|
| Atomicity | All or nothing | Undo/rollback, transaction log |
| Consistency | Constraints hold | Keys, checks, triggers |
| Isolation | Concurrent transactions do not interfere (per level) | Locks, MVCC |
| Durability | Committed data survives crashes | WAL/redo log flushed before commit |
Durability depends on settings: innodb_flush_log_at_trx_commit=1 (MySQL) and synchronous_commit=on (PostgreSQL) — relaxing them gains speed at the cost of losing recent commits on a crash.
In depth
Where each ACID property actually comes from
| Property | Provided by | Breaks when |
|---|---|---|
| Atomicity | Transaction log + rollback (undo or MVCC visibility) | Application commits half the work in separate transactions |
| Consistency | Constraints, foreign keys, triggers | Rules exist only in application code |
| Isolation | Locks and/or MVCC snapshots at the chosen isolation level | Level too low for the access pattern |
| Durability | Log flushed to stable storage before COMMIT returns | fsync disabled, write cache without power protection |
The durability chain
A COMMIT is only durable if every layer below it honours flush requests: database → OS page cache → filesystem → controller cache → disk. A RAID controller or SSD with a volatile write cache that ignores flushes can lose committed transactions on power loss even when the database is configured correctly.
Settings that trade durability for speed
| Engine | Setting | Effect |
|---|---|---|
| PostgreSQL | synchronous_commit = off | Recent commits can be lost on crash; no corruption |
| PostgreSQL | fsync = off | Crash can corrupt the cluster — never in production |
| MySQL InnoDB | innodb_flush_log_at_trx_commit = 2 | Log written at commit, flushed once a second; up to ~1 s lost on OS crash |
| MySQL | sync_binlog = 0 | Binary log may lose transactions the engine kept |
| SQL Server | Delayed durability | Commits acknowledged before the log is hardened |
Worked check
SHOW synchronous_commit; SHOW fsync; -- PostgreSQL
SELECT @@innodb_flush_log_at_trx_commit, @@sync_binlog; -- MySQL (1 and 1 = fully durable)
Common mistakes
- Assuming every engine/configuration gives full durability (check fsync settings).
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.