Concurrency Control Flashcards
Ghost update type b: when does it happen.
Can it be managed with 2PL?
On insert or group by.
2PL cannot managed it, predicate locking yes.
Definition of transaction
A sequence of read and write operations characterized by the same TID
Schedule definition
sequence of read/write operations presents by concurrent transactions
Concurrency control accepts or rejects schedules to avoid anomalies, the scheduler though has to accept or reject op. execution without knowing the outcome of the transactions (abort/commit)
Serializable schedule
Si is serializable when Si is equivalent to an arbitrary serial shedule of the same transactions.
View equivalence and view serializable schedule
Two schedules are view equivalent if they have the same reads-from set and the same final write set.
A schedule is view serializable if it is view equivalent to an arbitrary serial schedule of the same transactions.
Prevents: lost update: inconsistent read, ghost update (a).
Detecting view equivalence to a given schedule is O(n).
Detecting view equivalence to an arbitrary serial schedule is NP-complete (not feasible).
Scheduler
- Block of the concurrency control maanger
- is in charge of deciding if and when read/write requests can be satisfiedd
Without a scheduler we may have correctness problems
Lost Update
Dirty Read
Inconsistent read
Value is read 2 times, and reads different values during the same T.
Ghost update (a)
T1 only partially observes the effect of T2.
All objects are already present.
Ghost updates result from inconsistent reads.
Ghost update (b)
Inconsistent read.
A new set of objects are inserted by another transaction.
Commit projection
Is a simplifying hypothesis: the schedule contains only transactions performing commit
Equivalence classes
- View equivalence
- Conflict equivalence
- 2PL
- Timestamp equivalence
Each detecs a set of acceptable schedules, and is characterized by a different complexity in detecting equivalence.
Conflict equivalence, conflict serializable
Conflicting actions: Action Ai is in conflict with Aj (i != j) if both action operate on the same object and at least one of them is a write:
- Read-Write conflicts (RW or WR)
- Write-Write conflicts
Two schedules are conflict equivalent if they have the same conflict set and each conflict pair is in the same order in both schedules.
Conflict serializable: if it is equivalent to an arbitrary serial schedule of the same transactions.
CSR: conflict serializable schedules.
Detecting conflict serializability is possible through a conflict graph.
CSR is a subset of VSR.
Conflict graph
A node for each transaction.
An edge Ti -> Tj if:
- there exist at least a conflict between the two
- Ai preceeds Aj
Checking for cycles is O(V + E).