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.
with X = 50 and Y =50 (initial values)
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.
I hope Lost update problem is clear now, please share your thoughts/ideas on the same using comments section below:
You may also be interested in some of the trending topics in Machine Learning: