concurrency control by validation (18.9) by: pushkar marathe id: 217

12
Concurrency Control Concurrency Control by Validation by Validation (18.9) (18.9) By: By: Pushkar Marathe Pushkar Marathe Id: 217 Id: 217

Post on 21-Dec-2015

221 views

Category:

Documents


0 download

TRANSCRIPT

Concurrency Control by Concurrency Control by ValidationValidation

(18.9)(18.9)

By:By:

Pushkar MarathePushkar Marathe

Id: 217Id: 217

AgendaAgenda

OverviewOverview

Architecture of the schedulerArchitecture of the scheduler

Validation rulesValidation rules

ExampleExample

Comparison of concurrency control mechanismsComparison of concurrency control mechanisms

OverviewOverview

Type of optimistic concurrency control.Type of optimistic concurrency control.

Scheduler keeps a record of transactions Scheduler keeps a record of transactions rather than timestamps. rather than timestamps.

Validation phase before writing values into Validation phase before writing values into database.database.

ArchitectureArchitecture

Scheduler should know the read and write sets Scheduler should know the read and write sets for each transaction.for each transaction.

Three phases of transactions:Three phases of transactions:1.1. Read: Reads from database to read set.Read: Reads from database to read set.2.2. Validate: Validates by comparing the read and write sets Validate: Validates by comparing the read and write sets

with other transactions.with other transactions.3.3. Write: Writes from write set to database.Write: Writes from write set to database.

Serial order is maintained based on which the Serial order is maintained based on which the scheduler decides whether to validate or not.scheduler decides whether to validate or not.

To support the decision of validating To support the decision of validating three sets are maintained:three sets are maintained:

1.1. START: Set of all active transactions that are not START: Set of all active transactions that are not validated.validated.

2.2. VAL: Set of all transactions that are validated and VAL: Set of all transactions that are validated and are still active.are still active.

3.3. FIN: Set of all transactions that have finished FIN: Set of all transactions that have finished execution. For these the scheduler records execution. For these the scheduler records START(T),VAL(T),FIN(T).START(T),VAL(T),FIN(T).

Validation RulesValidation Rules

Suppose there is a transaction U such that:Suppose there is a transaction U such that:

a)a) U is in VAL or FIN; that is, U has validated.U is in VAL or FIN; that is, U has validated.b)b) FIN(U)>START(T); that is, U did not finish before T started.FIN(U)>START(T); that is, U did not finish before T started.c)c) RS(T) RS(T) ΠΠ WS(U) is not empty; in particular, let it contain WS(U) is not empty; in particular, let it contain

database element X.database element X.

T reads X

U writes X

U startT start

U validatedT validating

Figure 1

Here it is possible that U writes X after T Here it is possible that U writes X after T reads X. to make sure that T got to read reads X. to make sure that T got to read U’s value we need to rollback T to avoid a U’s value we need to rollback T to avoid a risk that the actions of T and U will be risk that the actions of T and U will be consistent with the serial order.consistent with the serial order.

T reads X

U writes X

U validatingT validating U finish

Suppose there is a transaction U such that:

a) U is in VAL or FIN; that is, U has validated.b) FIN(U)>START(T); that is, U did not finish before T started.c) 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 T and U both write values of X and if we validate T then it will write X before U. validate T then it will write X before U. Here also we rollback T so that order is Here also we rollback T so that order is not violated. not violated.

Comparison of three concurrency-Comparison of three concurrency-control Mechanismscontrol Mechanisms

Storage UtilizationStorage UtilizationLocks : Space in lock table proportional to Locks : Space in lock table proportional to number of database elements lockednumber of database elements locked

Timestamps : Space proportional to database Timestamps : Space proportional to database elements that have been accessed recently.elements that have been accessed recently.

Validation : Space proportional to currently Validation : Space proportional to currently active transactions and some transactions that active transactions and some transactions that finished just some time before the current finished just some time before the current started.started.

We can also compare based on ability of We can also compare based on ability of transactions to complete without delay.transactions to complete without delay.

Locking delays transactions but avoids Locking delays transactions but avoids rollback. rollback.

If interface is low, then neither timestamps nor If interface is low, then neither timestamps nor validations will cause rollbacks.validations will cause rollbacks.

When rollback necessary timestamps can When rollback necessary timestamps can catch problems earlier than validation.catch problems earlier than validation.

THANK YOU