Database Systems · Concurrency Control (Locking)
Concurrency Control Protocols Overview
Overview
A schedule is correct only if it is equivalent to some serial schedule.
Earlier methods tested this equivalence after the schedule had already executed; concurrency control protocols instead enforce rules during execution so that only safe (serializable-equivalent) schedules are produced.
Locking is the main mechanism: a data item is locked, and the rules decide when to lock, when to release, and who may access it.
Key concepts
- Schedule correctness: a schedule must give correct answers or consistent results, i.e. it must be equivalent to a serial schedule.
- Serializability testing (conflict serializable / view serializable): a post-execution check asking whether the executed schedule is equivalent to some serial schedule.
- Protocol: simply a rule.
- Concurrency control protocols: concurrency control rules; if they are followed, the generated schedules are equivalent to serial schedules.
- Safe execution: an operation that is about to violate a rule (for example a serializability rule) is not allowed; the schedule can execute only if it is equivalent to a serial schedule.
- Locking: locking a data item; a lock can be applied at any level. Locking rules must specify when to lock, when to release the lock, and who can access the data item.
- Lock-based protocols: locking a data item at any level, with rules for when to lock, when to release, and who can access. Two types:
- Two-phase locking protocol (2PL): Basic 2PL, Conservative 2PL, Strict 2PL, Rigorous 2PL
- Graph-based protocol
- Timestamp-based protocols: based on the values of the times at which data is accessed. Two varieties: Timestamp ordering protocol and Thomas Write Rule.
- Multi-granularity protocol: a listed protocol family.
- Multi-version protocol: a listed protocol family, with variants multi-version 2PL and a second multi-version variant (name unclear in the source).
Drawing the diagram…
How it works
- A schedule must be equivalent to a serial schedule to be correct.
- Earlier tests check this equivalence after execution.
- Concurrency control protocols instead give rules that are checked while the schedule is executing.
- If an operation would violate the rule, it is not permitted.
- Thus the protocol prevents the schedule from becoming non-serializable.
Protocol families covered:
- Lock-based protocols
- Locking a data item at any level.
- Rules specify when to lock, when to release, and who can access.
- Types: Two-phase locking protocol (2PL) (Basic 2PL, Conservative 2PL, Strict 2PL, Rigorous 2PL) and Graph-based protocol.
- Timestamp-based protocols
- Based on the values of the times at which data is accessed.
- Varieties: Timestamp ordering protocol and Thomas Write Rule.
- Multi-granularity protocol
- Multi-version protocol
- Variants: multi-version 2PL and a second multi-version variant (name unclear in the source).
Comparison
| Aspect | Serializability testing (conflict / view) | Concurrency control protocol |
|---|---|---|
| When applied | After execution of the schedule | During execution |
| What it does | Tests whether the schedule is equivalent to a serial schedule | Enforces rules so that the schedule remains equivalent to a serial schedule |
| Action on violation | The schedule is identified as not serializable after the fact | The violating operation is not allowed |
| Result | Accept or reject the schedule after execution | Generates only safe schedules that are equivalent to serial schedules |
| Protocol family | Basis | Variants listed |
|---|---|---|
| Lock-based | Locks on data items; rules for when to lock, when to release, and who can access | Two-phase locking: Basic 2PL, Conservative 2PL, Strict 2PL, Rigorous 2PL; Graph-based protocol |
| Timestamp-based | Values of times at which data is accessed | Timestamp ordering protocol; Thomas Write Rule |
| Multi-granularity | Protocol family based on multiple levels/granularities | — |
| Multi-version | Protocol family using multiple versions | Multi-version 2PL; second variant (name unclear) |
Revision summary
- A protocol means a rule; concurrency control protocols are rules that ensure schedules are equivalent to serial schedules.
- Serializability tests (conflict / view) are post-execution checks; protocols control the schedule during execution.
- If an operation would violate a protocol rule, it is not allowed.
- Locking means locking a data item; locking rules decide when to lock, when to release, and who can access.
- Lock-based protocols: Two-phase locking (Basic 2PL, Conservative 2PL, Strict 2PL, Rigorous 2PL) and Graph-based protocol.
- Timestamp-based protocols depend on the times of data access: Timestamp ordering protocol and Thomas Write Rule.
- Other families: Multi-granularity protocol and Multi-version protocol (with multi-version 2PL and a second variant).
- Memorize the exact classification and names of the variants.
Previous-year exam insights
- Basic 2PL guarantees conflict serializability but does not prevent deadlock; Conservative 2PL is deadlock-free (all locks acquired before execution) but not starvation-free; Strict/Rigorous 2PL prevent cascading rollback.
Asked inGATE 2010 - Timestamp ordering protocol ensures conflict serializability and is deadlock-free (no locks are used), but it is not starvation-free because conflicting transactions may be repeatedly aborted and restarted.
Asked inGATE 2010 - Deadlock prevention by transaction timestamps uses the wait-die and wound-wait schemes: in wait-die an older transaction waits and a younger one is killed; in wound-wait an older transaction wounds (kills) the younger holder and a younger requester waits.
Asked inGATE 2017 - A timestamp-based deadlock-prevention scheme that always kills the requester (or always kills the holder) is deadlock-free but not starvation-free, because the same transaction may be repeatedly killed and restarted.
Asked inGATE 2017 - Lock-based protocols (2PL) can suffer deadlock and starvation; timestamp-based protocols avoid deadlock but can suffer starvation, so no single basic protocol guarantees both conflict serializability and freedom from deadlock and starvation simultaneously.
Asked inGATE 2010 - The Thomas Write Rule: if a transaction's write timestamp is older than the item's write timestamp, the write is ignored (not executed) rather than aborting the transaction, which can make some non-conflict-serializable schedules acceptable.