Lost-Update-Problem in Concurrent schedules

In a schedule, if update performed by transaction T1 on data item ‘X’ gets overwritten by the update performed by transaction T2 on same data item ‘X’, then we say that update of T1 is lost to the update of T2.

This problem is known as Lost-Update-Problem in concurrent schedules.

Example:

with X = 50 and Y =50 (initial values)

T1 T2
read(x) (T1I1)
x=x+10 (T1I2)
read(x) (T2I1)
x=x+20 (T2I2)
write(x) (T1I3)
read(y) (T1I4)
write(x) (T2I2)
commit (T2I2)
y=y+10 (T1I5)
write(y) (T1I6)
commit (T1I7)

Explanation:

in concurrent execution,

  • T1 reads data item X(=50) from DB and increment its value by 10. (till now it has not performed any write and commit operation)
  • now T2 reads data item X(=50 because T1 has not performed any write and commit) from DB and increment it by 20.
  • T1 writes X. it will write X = 60 (50+10) in local cache. it has not perform any commit so value will not be updated in DB.
  • T1 read Y(=50).
  • T2 writes X. As T2 performed x=x+20 which x=70 will be written to local cache.
  • T2 performs commit which will write x=70 from local cache to DB. Now DB holds X value as 70.
  • Here in this step value of X which is updated as 60 in local cache but not committed to DB is lost to the update done by T2. it is defined as Lost Update Problem.
  • Now T1 will increment Y by 10. (Y = 60 after increment)
  • T1 will write Y = 60 to local cache.
  • T1 commit will update Y value as 60 to DB.
  • final X = 70 and Y = 60 values will be there in DB.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s