Thursday, April 21, 2016

Concurrency Anomalies - Incorrect Summary Problem

Need for concurrency control, Concurrency Anomalies, Concurrent Execution Problems
Incorrect Summary / Inconsistent Analysis problem

This problem is caused when one of the transactions is executing an aggregate operation on several data items, and other transactions are updating one or more of those data items. This causes a inconsistent database state.

Example:

Consider the schedule S1 given below, in which, transaction T1 transfers money from account A to account B and in the mean time, transaction T2 calculates the sum of 3 accounts namely, A, B, and C. The third column shows the account balances and calculated values after every instruction is executed.

Transaction T1
Transaction T2
A = 1000, B = 1000, C = 1000




read(A);
A := A – 50;
write(A);






read(B);
B := B + 50;
write(B);
commit;
sum = 0;
avg = 0;
read(C);
sum := sum + C;



read(A);
sum := sum + A;
read(B);
sum := sum + B;
avg := sum/3;
commit;
sum  = 0
avg = 0
T2 read: C = 1000
sum = 1000
T1 read: A = 1000

T1 write: A = 950
T2 read: A = 950
sum = 1950
t2 read: B = 1000
sum = 2950
avg = 983.33

T2 read: B = 1000

T2 write: B = 1050

Discussion:

Transaction T2 reads the value of account A after A is updated and reads B before B is updated. [The portion that violates in T2 is highlighted in green color]. Hence, the aggregate operation is end up with an inconsistent result.
If all the instructions in T1 are executed before T2 starts, then A will be 950, B will be 1050 and average value will be 1000.
If all the instructions in T1 are executed after T2 finishes, then A will be 950, B will be 1050 and average value will be 1000.
But, due to this interleaved execution, the final value of A is 950, B is 1050, and average is 983.33 which is wrong.
This problem is called as Inconsistent analysis or Incorrect summary problem. This is caused due to the interleaved execution of multiple simultaneous transactions that are working on same data items.

******************

Go to Transaction Management in DBMS home page









1 comment:

  1. Thanks for such a valuable and informative platform I find here. I am regular to read publication of this blog and definitely waiting for more articles.
    coach new york

    ReplyDelete

Featured Content

Multiple choice questions in Natural Language Processing Home

MCQ in Natural Language Processing, Quiz questions with answers in NLP, Top interview questions in NLP with answers Multiple Choice Que...

All time most popular contents