Skip to main content
Web DevDatabases & CachingDiagramIntermediate

ACID Transaction

KO: ACID 트랜잭션·EN: ACID Transaction·JA: ACIDトランザクション·Atomicity · Consistency · Isolation · Durability

A database guarantee bundling multiple operations into an indivisible unit enforcing Atomicity, Consistency, Isolation, and Durability even under crashes or concurrency

Table of Contents

Structure Diagram

ACID Transaction Execution, Verification & Commit/Rollback
ACID TX1. BEGIN (Is…2. Execute M…3. Consisten…4. COMMIT or…
2/42. Execute Mutations
Debit (-100) + Credit (+100)
Quick Answer

What is ACID Transaction?

A database guarantee bundling multiple operations into an indivisible unit enforcing Atomicity, Consistency, Isolation, and Durability even under crashes or concurrency. It is a core concept in Databases & Caching within Web Dev.

Core Principles

When multiple writes must succeed or fail together—such as debiting one bank account and crediting another—databases enforce ACID guarantees:

  • Atomicity: All-or-nothing execution (COMMIT everything or ROLLBACK completely on error).
  • Consistency: Every constraint (foreign keys, unique keys, check constraints) holds before and after the transaction.
  • Isolation: Concurrent transactions do not corrupt each other, tuned via isolation levels (Read Committed, Repeatable Read, Serializable).
  • Durability: Once committed, changes survive crashes and power loss via Write-Ahead Logging (WAL).

Practical Takeaways

  • Never call external HTTP APIs inside a DB transaction: Network stalls hold locks and exhaust the connection pool. Keep transactions strictly local to the DB and use the Transactional Outbox pattern for external side effects.
  • Know your engine's default isolation level: PostgreSQL defaults to Read Committed; MySQL InnoDB defaults to Repeatable Read. Guard hot inventory or balance updates explicitly with SELECT ... FOR UPDATE or optimistic locking to avoid lost updates.
  • Keep transactions short: Perform validation and read-heavy prep before opening the transaction so lock contention stays minimal.

Notable Examples

  • Financial ledgers & payments: Atomically recording debit, credit, audit log, and idempotency keys in one transaction.
  • E-commerce checkout: Rolling back inventory reservations and order rows automatically if coupon redemption fails.