CSE 414 Section 6
Serializability & Locking
May 4th, 2023
Announcements
Recap: Definitions
Operation - read or write of an element (later: insert or delete)
Transaction - series of operations meant to have the ACID guarantees
Schedule - ordering of the operations of some txns
Serial schedule - schedule where each txn is executed one after another.� No interleaving
Serializable schedule - a schedule that is behaviorally equivalent � to a serial schedule
Definitions
Non-conflicting swap - �
Conflicting swap -
Conflict serializable schedule - �
Definitions
Non-conflicting swap - a pair of adjacent operations in a schedule � that can be reversed without affecting the schedule's behavior
Conflicting swap - (any two ops in different txn on the same element), RW, WR, WW
Conflict serializable schedule - a schedule that can be transformed � into a serial schedule via a series of non-conflicting swaps
Conflict Serializability
Checking for conflict serializability -> precedence graph and cycle checking
Conflict Serializability
Checking for conflict serializability -> precedence graph and cycle checking
Serializability
“Conflict serializable” is a stronger constraint than “serializable”
I.e. Any schedule that is conflict serializable must be serializable.
Serializable
Conflict
Serializable
Easy to check
Not easy to check
Serializability
S1: w1(Y); w2(Y); w1(X); w2(X); w3(X)
Are these serializable? Conflict serializable?
Serializability
S1: w1(Y); w2(Y); w1(X); w2(X); w3(X)
Conflict Serializable
Recap: ACID
Transactions have 4 main properties:
Locking Overview
Remember - locking is for database internal implementation
Database Lock
Table Lock
Predicate Lock
Tuple Lock
Lock Granularity
SQLite!
Less Concurrency
More Concurrency
All the Locks!
Lock Type | Benefit |
Binary Locks | Simplest lock implementation |
Shared/Exclusive Locks | Greater throughput on reads |
Binary Locks
2PL with Binary Locks
Lock growing phase
Lock shrinking phase
2PL vs. Strict 2PL
Invalid reads
Trickled unlock and transaction end
2PL vs. Strict 2PL
2PL:
Strict 2PL: