120 likes | 258 Views
Concurrency Control by Validation (18.9). By: Pushkar Marathe Id: 217. Agenda. Overview Architecture of the scheduler Validation rules Example Comparison of concurrency control mechanisms. Overview. Type of optimistic concurrency control.
E N D
Concurrency Control by Validation(18.9) By: Pushkar Marathe Id: 217
Agenda • Overview • Architecture of the scheduler • Validation rules • Example • Comparison of concurrency control mechanisms
Overview • Type of optimistic concurrency control. • Scheduler keeps a record of transactions rather than timestamps. • Validation phase before writing values into database.
Architecture • Scheduler should know the read and write sets for each transaction. • Three phases of transactions: • Read: Reads from database to read set. • Validate: Validates by comparing the read and write sets with other transactions. • Write: Writes from write set to database. • Serial order is maintained based on which the scheduler decides whether to validate or not.
To support the decision of validating three sets are maintained: • START: Set of all active transactions that are not validated. • VAL: Set of all transactions that are validated and are still active. • FIN: Set of all transactions that have finished execution. For these the scheduler records START(T),VAL(T),FIN(T).
T reads X U writes X T start T validating U start U validated Validation Rules • Suppose there is a transaction U such that: • U is in VAL or FIN; that is, U has validated. • FIN(U)>START(T); that is, U did not finish before T started. • RS(T) Π WS(U) is not empty; in particular, let it contain database element X. Figure 1
Here it is possible that U writes X after T reads X. to make sure that T got to read U’s value we need to rollback T to avoid a risk that the actions of T and U will be consistent with the serial order.
T reads X U writes X T validating U finish U validating • Suppose there is a transaction U such that: • U is in VAL or FIN; that is, U has validated. • FIN(U)>START(T); that is, U did not finish before T started. • RS(T) Π WS(U) is not empty; in particular, let it contain database element X.
T and U both write values of X and if we validate T then it will write X before U. Here also we rollback T so that order is not violated.
Comparison of three concurrency-control Mechanisms Storage Utilization • Locks : Space in lock table proportional to number of database elements locked • Timestamps : Space proportional to database elements that have been accessed recently. • Validation : Space proportional to currently active transactions and some transactions that finished just some time before the current started.
We can also compare based on ability of transactions to complete without delay. • Locking delays transactions but avoids rollback. • If interface is low, then neither timestamps nor validations will cause rollbacks. • When rollback necessary timestamps can catch problems earlier than validation.