Concurrency Control: Short Notes (Database Transactions)
Concurrency control is the set of mechanisms a database uses to coordinate concurrent execution of transactions so that the final result is as if transactions ran in some safe order (typically ensuring serializability). It targets common anomalies such as dirty reads, non-repeatable reads, and phantom reads, which arise when isolation is too weak. In transaction systems, concurrency control is tightly connected to ACID and to the database’s chosen isolation level.2
A useful way to structure concurrency control is:
- Define what correctness means (e.g., conflict serializability / serializability).
- Pick a control method (locking, timestamps, optimistic/MVCC).
- Handle failure modes like deadlock.
- Provide/verify isolation guarantees at the system level.
Key terms (for your short notes)
- transaction
- schedule
- serializability
- isolation level
- deadlock
Footnotes
-
ANSI SQL isolation levels / anomalies overview - Explains dirty read, non-repeatable read, phantom read and isolation levels. ↩
-
Serializability (database theory) - Defines serializability and its significance in correctness of concurrent schedules. ↩
Concurrency Control (Locks & Serializability) — educational overview
Correctness objective: serializability & anomalies
Concurrency control usually aims to prevent schedules that cannot be explained by a serial execution. The most common correctness notions are conflict serializability and (more generally) serializability. When violated, anomalies occur—commonly summarized through textbook read anomalies:
- Dirty read: Transaction reads data written by another transaction that later aborts.
- Non-repeatable read: Same row read twice yields different values because another committed transaction changed it between reads.
- Phantom read: Re-running a predicate query yields a new set of matching rows because another transaction inserted/removed qualifying rows.
[CalloutBlock]
type="warning"
title="Warning: ‘Locks’ ≠ ‘Isolation’ by default"
content="Using locks can enforce serializability, but the exact isolation guarantees depend on the locking rules (e.g., strictness), the isolation level semantics, and index/predicate locking for phantom protection."
Footnotes
-
Serializability (database theory) - Defines serializability and its significance in correctness of concurrent schedules. ↩
-
ANSI SQL isolation levels / anomalies overview - Explains dirty read, non-repeatable read, phantom read and isolation levels. ↩ ↩2 ↩3
Lock-based concurrency control (2PL)
Locking primitives
Lock-based methods use locks with compatibility rules (e.g., shared vs exclusive). Transactions acquire locks before reads/writes; they may release locks later (or not, depending on strategy). The standard formal pattern is captured by Two-Phase Locking (2PL).
Two-Phase Locking (2PL)
2PL requires that a transaction first enters a growing phase (acquiring locks) and then a shrinking phase (releasing locks). No new locks may be acquired after it begins releasing.
A stronger variant, strict 2PL, holds write locks until commit/abort, which additionally prevents dirty reads (and is widely used in practice because it simplifies reasoning about recovery consistency).
[CalloutBlock]
type="tip"
title="Pro Tip (short-notes phrasing)"
content="Write: '2PL = growing then shrinking phase; ensures conflict-serializability; strict 2PL prevents dirty reads by retaining X-locks until commit/abort'."
Footnotes
-
Two-phase locking - Presents 2PL rule and its role in ensuring serializability. ↩ ↩2
Deadlock handling
Locking-based concurrency can lead to deadlock when multiple transactions wait on locks held by each other. A common formalization uses a wait-for graph: an edge indicates is waiting for .
Typical deadlock strategies:
- Prevention: impose an order on resources so cycles cannot occur (reduces concurrency).
- Detection & resolution: build/scan the wait-for graph periodically; when a cycle exists, abort a victim transaction.
- Timeouts: abort a transaction if it waits too long (simpler, but may abort prematurely).
- Wound-wait / wait-die style policies: use transaction timestamps to decide whether the younger waits or the older preempts (often described in timestamp-based schemes).
[CalloutBlock]
type="danger"
title="Deadlock note for exams"
content="You can mention: 'Deadlocks occur with lock waits; detect cycles in the wait-for graph and abort a victim (or prevent using resource ordering)'. Avoid claiming a specific algorithm unless your syllabus states it."
Footnotes
Timestamp-based and optimistic approaches (high-level short notes)
Timestamp ordering
Timestamp-based concurrency control assigns each transaction a timestamp and orders conflicting operations by timestamp. If an operation would violate the timestamp order, it may be aborted or delayed depending on the specific algorithm.
Optimistic concurrency control & validation
Optimistic methods assume conflicts are rare: transactions run without heavy blocking, then validate before committing to ensure that the committed outcome is consistent with the correctness criteria.
MVCC (Multi-Version Concurrency Control)
Many modern databases use MVCC: readers use a snapshot, while writers create new versions. MVCC is designed to improve concurrency and reduce read-write blocking, often mapping naturally to isolation-level semantics like snapshot isolation.
Footnotes
-
Timestamp ordering (concurrency control) - Describes timestamp ordering approach for concurrency control. ↩
-
Multi-version concurrency control - Explains MVCC and its rationale in reducing blocking and enabling snapshot behavior. ↩ ↩2
Quick comparison chart (for “short notes”)
The following table compresses the major families of concurrency control into exam-friendly bullets.
| Method family | Typical idea | Main strengths | Main trade-offs |
|---|---|---|---|
| Lock-based (2PL) | Acquire/release locks; enforce order constraints | Strong correctness reasoning; good fit for strict isolation | Blocking and deadlocks possible |
| Timestamp-based | Enforce order by timestamps | Avoids some lock waits; systematic abort rules | May abort more under contention |
| Optimistic/MVCC | Assume no conflicts; validate or use versions | Better read concurrency; fewer blocking reads | Requires versioning/validation overhead |
(These are conceptual summaries consistent with standard descriptions of 2PL, timestamp ordering, optimistic/MVCC families.)3
Footnotes
-
Two-phase locking - Presents 2PL rule and its role in ensuring serializability. ↩
-
Timestamp ordering (concurrency control) - Describes timestamp ordering approach for concurrency control. ↩
-
Multi-version concurrency control - Explains MVCC and its rationale in reducing blocking and enabling snapshot behavior. ↩
How to describe concurrency control in an exam (structured answer)
- 1Step 1
Write: 'Ensure concurrent transactions produce results equivalent to some serial execution (serializability/isolation)'.
- 2Step 2
Mention dirty reads, non-repeatable reads, phantom reads as consequences of weak isolation.
- 3Step 3
Choose lock-based (2PL), timestamp ordering, or MVCC/optimistic; add one sentence about the principle.
- 4Step 4
If using locks: say deadlocks may occur and are handled by prevention or detection/aborting.
- 5Step 5
Example: '2PL ensures conflict serializability' or 'MVCC enables snapshot-like reads while preserving consistency'.
Conceptual evolution of concurrency control techniques
Serializability & isolation
FoundationsDefine correctness via serializability; classify anomalies by isolation level."
Locking (2PL)
Classical controlUse shared/exclusive locks and 2PL rules to ensure serializability."
Timestamps
Ordering-basedImpose a transaction order for conflicting operations."
Optimistic/MVCC
Modern systemsUse validation or multi-version snapshots to reduce blocking."
Isolation/anomaly prevention (conceptual)
A high-level comparison of which anomalies a scheme typically targets (varies by implementation).
Short-notes FAQs
Concurrency Control: quick recall deck
Knowledge Check
Which property ensures that the outcome of a concurrent schedule matches some serial execution order?