Study smarter with Fiveable
Get study guides, practice questions, and cheatsheets for all your subjects. Join 500,000+ students with a 96% pass rate.
Concurrency control sits at the heart of every system that handles multiple simultaneous operations—from databases serving thousands of queries to distributed applications coordinating across servers. You're being tested on your ability to understand why different techniques exist, when each approach makes sense, and what trade-offs developers face when choosing between them. The core tension you'll encounter repeatedly is the balance between consistency (ensuring correct results) and performance (maximizing throughput).
These techniques demonstrate fundamental principles in systems programming: serializability guarantees, deadlock management, isolation trade-offs, and optimistic vs. pessimistic strategies. Don't just memorize the names—know what problem each technique solves and when you'd choose one over another. If an exam question describes a scenario with high read traffic and rare conflicts, you should immediately recognize which approaches shine there.
These techniques assume conflicts are likely and prevent them upfront by restricting access. The philosophy: it's better to wait than to redo work.
Compare: Two-Phase Locking vs. Read-Write Locks—both use locks to prevent conflicts, but 2PL focuses on when locks are acquired/released while read-write locks focus on what type of access is permitted. FRQs often ask you to combine these: a system might use 2PL with read-write locks.
These techniques assume conflicts are rare and let transactions proceed freely, checking for problems only at commit time. The philosophy: validate at the end rather than block throughout.
Compare: OCC vs. MVCC—both avoid locking, but OCC validates at commit time and aborts on conflict, while MVCC uses versioning to let operations coexist. MVCC handles read-heavy loads better; OCC is simpler but more sensitive to conflict rates.
These techniques use timestamps or transaction order to determine which operations should win conflicts. The philosophy: establish a total ordering and enforce it.
Compare: Timestamp Ordering vs. 2PL—both guarantee serializability, but timestamp ordering aborts transactions that arrive late while 2PL makes them wait. Timestamp ordering eliminates deadlocks but increases abort rates; 2PL has lower abort rates but requires deadlock handling.
These techniques address what happens when concurrency control mechanisms create problems like deadlocks or when we need to tune the strictness of isolation.
Compare: Deadlock Prevention vs. Detection—prevention adds overhead to every transaction (ordering constraints, timestamp checks) but never has deadlocks. Detection allows deadlocks to occur but catches them quickly. High-contention systems often prefer prevention; low-contention systems use detection.
| Concept | Best Examples |
|---|---|
| Pessimistic locking | Two-Phase Locking, Read-Write Locks, Lock Granularity |
| Optimistic execution | Optimistic Concurrency Control, MVCC |
| Ordering-based control | Timestamp Ordering, Serialization Graph Testing |
| Correctness criteria | Conflict Serializability, Isolation Levels |
| Deadlock management | Deadlock Prevention and Detection, Two-Phase Locking |
| Read-heavy optimization | MVCC, Read-Write Locks, fine-grained locking |
| Write-heavy optimization | Coarse-grained locking, Two-Phase Locking |
| No-deadlock guarantees | Timestamp Ordering, Optimistic Concurrency Control |
Which two techniques guarantee serializability but differ in how they handle conflicts—one by waiting, one by aborting?
A system experiences high read traffic with occasional writes. Which concurrency control technique would minimize blocking, and why?
Compare and contrast Optimistic Concurrency Control and Two-Phase Locking: what assumptions does each make about conflict frequency, and how does this affect their performance characteristics?
If you construct a serialization graph and find a cycle, what does this tell you about the schedule? What are your options for resolving the problem?
An FRQ describes a system using Read Committed isolation that's experiencing non-repeatable reads. Explain why this anomaly occurs and what isolation level change would prevent it—along with the trade-off involved.