Course: Data Science and Database Technologies
Source: Concurrency Control, local path 17-ConcurrencyControl_new.pdf, 79 PDF pages. The source displays the Data Base and Data Mining Group (DBMG) mark; no individual lecturer name is printed on the slides. Lecture number 17 follows the supplied filename identifier.
Lecture summary
Concurrency control coordinates simultaneous read (r(x)) and write (w(x)) operations across concurrent transactions so the DBMS maximizes throughput (transactions per second) and minimizes response time without corrupting data. Without a scheduler, interleaved execution causes five classic anomalies: lost update, dirty read, inconsistent read, ghost update (a) (partial observation of a multi-object update), and ghost update (b) (phantom insert of a row that did not exist yet).
Serializability theory defines a schedule as correct (under the temporary commit projection assumption) when it equals some serial schedule. View serializability (VSR) compares reads-from and final write sets exactly, but testing equivalence to an arbitrary serial schedule is NP-complete. Conflict serializability (CSR) narrows focus to conflicting pairs (RW, WR, WW on the same object) and reduces testing to checking whether the conflict graph is acyclic (). Because updating and cycle-checking a live conflict graph on every page access is still too expensive at high transaction rates, commercial DBMSs enforce serializability using Two-Phase Locking (2PL) (). Dropping the commit-projection assumption requires Strict 2PL, which holds all locks until COMMIT or ROLLBACK to eliminate dirty reads and cascade rollbacks.
To balance concurrency and lock-manager overhead across database sizes, hierarchical locking adds intention locks (ISL, IXL, SIXL) alongside SL and XL with a top-down acquisition and bottom-up release protocol. Predicate locking (implemented via index locking) prevents ghost update (b) inserts. The SQL2 standard exposes four isolation levels—SERIALIZABLE, REPEATABLE READ, READ COMMITTED, and READ UNCOMMITTED—relaxing read locks only while keeping writes under Strict 2PL exclusive locks. Finally, because gradual lock acquisition can cause deadlocks, systems resolve them via timeout (commercial default), prevention (Pessimistic 2PL or timestamps), or detection via a wait graph (distributed DBMS).
Learning route
- Revisit prerequisites: Transactions and ACID Properties and DBMS Architecture and Query Processing.
- Read Concurrency Anomalies and Serializability Theory for the five anomalies, VSR, CSR, and conflict graphs.
- Read Two-Phase Locking and Strict 2PL for the lock manager, conflict table, 2PL phases, Strict 2PL, and runtime conflict probabilities.
- Read Hierarchical Locking Predicate Locking and SQL2 Isolation Levels for granularity levels, intention locks, predicate locking, and SQL2 isolation semantics.
- Read Deadlock Handling in Concurrency Control for deadlock formation and timeout vs. prevention vs. wait-graph detection.
Source map
| PDF pages | Material |
|---|---|
| 1–12 | DBMS architecture placement, workload (tps), elementary r/w operations, scheduler role, and the five anomalies |
| 13–29 | Schedules, commit projection, serializability, View Equivalence (reads-from, final write), VSR anomaly proofs, and NP-completeness |
| 30–37 | Conflict Equivalence (RW/WR/WW), CSR, conflict graph test, runtime cost analysis, and CSR ⊂ VSR |
| 38–57 | Read/write locks, conflict table, lock manager, 2PL (2PL ⊂ CSR ⊂ VSR), Ghost Update (a) 2PL trace, Strict 2PL, service interface, and timeouts |
| 58–70 | Hierarchical locking (granularity tree, SL/XL/ISL/IXL/SIXL, request protocol, compatibility matrix, precedence graph) and predicate locking |
| 71–74 | SQL2 transaction modes (READ ONLY/READ WRITE) and isolation levels (SERIALIZABLE, REPEATABLE READ, READ COMMITTED, READ UNCOMMITTED) |
| 75–79 | Deadlocks, timeout resolution, deadlock prevention (Pessimistic 2PL, timestamps), and wait-graph detection |
Worked examples from the source
1. The five concurrency anomalies (Slides 6–12)
| Anomaly (Slides) | Schedule / Scenario | Correctness failure |
|---|---|---|
| Lost update (6) | Initial x=2; reads 2, reads 2, writes 3, commits; writes 3, commits | Final x=3 instead of 4; ‘s update is lost |
| Dirty read (7) | writes w₁(x) (x=3); reads 3, writes 4, commits; aborts | committed using uncommitted data (requires cascade rollback) |
| Inconsistent read (8) | reads x=2; writes x=3 and commits; reads x=3 | Same transaction reads x twice with different results |
| Ghost update (a) (9–10) | x=400, y=300, z=300; reads x=400, y=300; transfers 100 (y=200, z=400) and commits; reads z=400 | partially observes and computes total = 1100 instead of 1000 |
| Ghost update (b) (11–12) | computes AVG(salary) in dept x; inserts a new employee in dept x and commits; recomputes AVG(salary) | The newly inserted row did not exist before ‘s first read |
2. Conflict graph test for CSR (Slides 31–35)
For :
- Conflicts on
x: , , . - Conflicts on
z: , , . - Because the resulting graph has no cycles, is CSR (equivalent serial schedule : ).
3. CSR schedule rejected by 2PL (Slide 50)
For :
- Conflict graph edges are (on
x) and (ony), which is acyclic (), so is CSR. - However, had to release its lock on
xso could proceed, and later had to acquire a new lock onyfor —violating 2PL’s rule against acquiring locks after any release.
4. How 2PL stops Ghost Update (a) (Slides 51–52)
When reads x and y under shared R-Locks, 2PL prevents from unlocking y before acquiring r_lock₁(z). Consequently, ‘s w_lock₂(y) request is forced to wait while reads the consistent pre-transfer z = 300, computes 1000, commits, and unlocks x, y, z, after which acquires its write locks and completes. See Two-Phase Locking and Strict 2PL for the full step-by-step trace.
Added clarifications in the linked concept notes (such as the x, y, z gradual locking trace and the cycle check ) are explicitly marked as added study explanations outside the PDF.
Revision prompts
- Compare all five concurrency anomalies and explain why row-level locking cannot stop ghost update (b).
- Distinguish VSR from CSR and trace why is CSR while is CSR but not 2PL.
- Contrast Basic 2PL, Strict 2PL, and Pessimistic 2PL on lock acquisition timing, lock release timing, dirty reads, and deadlocks.
- Trace the 5×5 hierarchical locking compatibility matrix and explain when
SIXLis needed. - Compare SQL2
SERIALIZABLE,REPEATABLE READ,READ COMMITTED, andREAD UNCOMMITTED—including what happens to write locks at every level. - Compare timeout, prevention, and wait-graph deadlock strategies and explain the risk of a too-short timeout.
Source and scope
Data Base and Data Mining Group (DBMG), Concurrency Control, local path 17-ConcurrencyControl_new.pdf, 79 PDF pages. This note paraphrases and organizes the source material; added study traces in the concept notes are labeled explicitly.