150 likes | 329 Views
Section 18.9 Concurrency Control by Validation Praveen AP. CS 255. Validation. Optimistic concurrency control Scheduler maintains record of active transactions Concurrency Control assumes that conflicts between transactions are rare Does not require locking
E N D
Section 18.9 Concurrency Control by Validation Praveen AP CS 255
Validation • Optimistic concurrency control • Scheduler maintains record of active transactions • Concurrency Control assumes that conflicts between transactions are rare • Does not require locking • Check for conflicts just before commit
PhasesRead – Validate - Write • Read • Reads from the database for the elements in its read set • ReadSet(Ti): Set of objects read by Transaction Ti. • Whenever the first write to a given object is requested, a copy is made, and all subsequent writes are directed to the copy • When the transaction completes, it requests its validation and write phases
PhasesRead– Validate - Write • Validation • Checks are made to ensure serializability is not violated • Scheduling of transactions is done by assigning transaction numbers to each transactions • There must exist a serial schedule in which transaction Ti comes before transaction Tj whenever t(i) < t(j) • If validation fails then the transaction is rolled back otherwise it proceeds to the third phase
PhasesRead- Validate - Write • Write • Writes the corresponding values for the elements in its write set • WriteSet(Ti): Set of objects where Transaction Ti has intend to write on it. • Locally written data are made global
Terminologies • Scheduler maintains 3 states • START(T), VAL(T), FIN(T) • START • Transactions that are started but not yet validated • VAL • Transactions that are validated but not yet finished • FIN • Transactions that are finished • Every transaction has rs{C,D..}, ws{A,B..}
Validation Rule 1 • T1 • T2 • T2 starts before T1 finishes • FIN(T1) > START(T2) • RS(T2) WS(T1) = TimeLine Write Validation Read
Validation Rule 2 TimeLine T1 T2 T2 starts before T1 finishes FIN(T1) > VAL(T2) WS(T2) WS(T1) = Interference – Leads to Rollback of T2 Validation Write No Problem
RS(Tj) WS(Ti) = FIN(Ti) > START(Tj) Rule 1WS(Tj) WS(Ti) = FIN(Ti) > VAL(Tj) Rule 2 where j > i TimeLine RS Validation WS T1 A,B A,C T2 B D T3 B D,E T4 A,D A,C
Validation • T2 & T1 • RS(T2) WS(T1) = {B} {A,C} = • WS(T2) WS(T1) = {D} {A,C} = • T3 & T1 • RS(T3) WS(T1) = {B} {A,C} = • WS(T3) WS(T1) = {D,E} {A,C} = • T3 & T2 • RS(T3) WS(T2) = {B} {D} = • WS(T3) WS(T2) = {D,E} {D} = D// Rule 2 Can't be applied; FIN(T2) < VAL(T3)
Validation • T4 Starts before T1 and T3 finishes. So T4 has to be checked against the sets of T1 and T3 • T4 & T1 • RS(T4) WS(T1) = {A,D} {A,C} = {A} • Rule 2 can not be applied • T4 & T3 • RS(T4) WS(T3) = {A,D} {D,E} = {D} • WS(T4) WS(T3) = {A,C} {D,E} =
Comparison • Validation • Optimistic Concurrency Control is superior to locking methods for systems where transaction conflict is highly unlikely, e.g query dominant systems. • Avoids locking overhead • Starvation: What should be done when validation repeatedly fails ? • Solution: If the concurrency control detects a starving transaction, it will be restarted, but without releasing the critical section semaphore, and transaction is run to the completion by write locking the database
Comparison • Lock • Lock management overhead • Deadlock detection/resolution. • Concurrency is significantly lowered, when congested nodes are locked. Locks can not be released until the end of a transaction • Conflicts are rare. (We might get better performance by not locking, and instead checking for conflicts at commit time.)?
Comparison • Timestamp • Deadlock is not possible • Prone to restart
Questions Thank you