Durability in ACID Database Transactions
Fast recall
Quick revision
Core answer
Whether the candidate understands durability as a crash-recovery guarantee within a database's configured storage policy and can explain a common WAL or redo-log implementation.
Treating durability as protection from every disaster, or assuming every acknowledged commit performs its own physical `fsync` regardless of database settings and group commit.
Separate crash recovery from backups and replication, and explain that synchronous-commit settings define when the database may acknowledge success.
Interview-ready guide
Interview answer
Durability means that after the database acknowledges a commit, it can recover that transaction after a restart within the configured storage guarantee.
Many engines achieve this with a write-ahead or redo log: the recovery information becomes durable before the changed data pages, and recovery replays it if needed. The details differ by engine. PostgreSQL uses WAL and redo-oriented recovery; InnoDB uses a redo log plus separate undo information.
Synchronous commit settings may wait for durable storage, while asynchronous modes can acknowledge earlier and accept a loss window. Group commit can share a flush across transactions. Durability is not a backup and cannot by itself protect against a destroyed disk or an accidental delete, so replicas and tested backups still matter.
Durability in ACID Database Transactions
Direct Answer
Durability means a successfully committed transaction survives a database restart or crash within the storage guarantees the system is configured to provide. Many databases make the commit record durable in a write-ahead or redo log before acknowledging success, then use that log during recovery. Durability settings, replicas, backups, and storage failures still define the real protection boundary.
Code Example
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.Instant;
@Service
public class PaymentService {
private final PaymentRepository paymentRepo;
public PaymentService(PaymentRepository paymentRepo) {
this.paymentRepo = paymentRepo;
}
@Transactional
public Payment recordPayment(String providerRef, BigDecimal amount) {
var payment = new Payment(providerRef, amount, Instant.now());
return paymentRepo.save(payment);
}
}
// When the transaction manager successfully commits, durability is supplied
// by the database and its configured commit policy—not by the annotation itself.
Common Mistakes & Pitfalls
- Calling durability a backup: Crash recovery cannot restore data that was deliberately deleted or storage that was destroyed; use tested backups and replication for those failures.
- Assuming a fixed flush path: Commit latency depends on engine, storage, synchronous settings, and group commit. It is not always one
fsyncper transaction. - Assuming one WAL design: PostgreSQL recovery is redo-oriented, while InnoDB combines redo with separate undo information. Learn the selected engine's mechanism.
Check your understanding
Answer these without looking back at the article.
- What is Write-Ahead Logging (WAL)?
- How does MySQL configure durability vs performance trade-off?
- Is Durability sufficient protection against hardware failure?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.