Concurrency Control Techniques: By, Dr. P. Gayathri Associate Professor Scope VIT University
Concurrency Control Techniques: By, Dr. P. Gayathri Associate Professor Scope VIT University
Concurrency Control Techniques: By, Dr. P. Gayathri Associate Professor Scope VIT University
Techniques
By,
Dr. P. Gayathri
Associate Professor
SCOPE
VIT University
Example:
In concurrent execution environment if T1 conflicts with T2
over a data item A, then the existing concurrency control
decides if T1 or T2 should get the A and if the other
transaction is rolled-back or waits.
Dr. P. Gayathri, Associate Professor, SCOPE, VIT
Concurrency control Protocols
Concurrency control techniques ensures serializability
of schedules by using procotols (set of rules)
Locking method
Timestamp method
Multi version method
Validation method
Essential components
Lock Manager:
Controls or Manages locks on data items.
Lock table:
Lock manager uses it to store the identity of transaction
locking a data item.
Items not in the lock table are considered to be unlocked.
Y N
Write
N N
T1 T2 Result
read_lock (Y); read_lock (X); Initial values: X=20; Y=30
read_item (Y); read_item (X); Result of serial execution
unlock (Y); unlock (X); T1 followed by T2
write_lock (X); Write_lock (Y); X=50, Y=80.
read_item (X); read_item (Y); Result of serial execution
X:=X+Y; Y:=X+Y; T2 followed by T1
write_item (X); write_item (Y); X=70, Y=50
unlock (X); unlock (Y);
Reason: Y in T1 and X in T2 were unlocked too early
T1 T2 Result
read_lock (Y); X=50; Y=50
read_item (Y); Nonserializable
unlock (Y);
read_lock (X);
read_item (X);
unlock (X);
write_lock (Y);
Time read_item (Y);
Y:=X+Y;
write_item (Y);
unlock (Y);
write_lock (X);
read_item (X);
X:=X+Y;
write_item (X);
unlock (X);
T’1 T’2
read_lock (Y); read_lock (X); T1 and T2 follow two-phase
read_item (Y); read_item (X); policy but they are subject to
write_lock (X); Write_lock (Y); deadlock, which must be
unlock (Y); unlock (X); dealt with.
read_item (X); read_item (Y);
X:=X+Y; Y:=X+Y;
write_item (X); write_item (Y);
unlock (X); unlock (Y);
Conservative (static):
Prevents deadlock by locking all desired data items before transaction
begins execution.
Pre-declaring read set (set of all items that transaction reads) and write set
(set of all items that transaction writes)
If any of the pre-declared items cannot be locked, transaction does not lock
any item and it waits until all items are available for locking
Deadlock free protocol
Difficult to use in practice because pre-declaration of read set and write set
is not possible in most situations
Rigorous:
Does not unlock any of its item until after it terminates (by
committing or aborting)
Transaction is in expanding phase (new locks can be acquired
but none can be released) until it ends