Lost Update
丢失更新:提交或者回滚一个事务,把其它事务已提交的更新的数据覆盖了。
If the two transactions want to change the same columns, the second transaction will overwrite the first one, therefore losing the first transaction update.
In this example Bob is not aware that Alice has just changed the quantity from 7 to 6, so her UPDATE is overwritten by Bob’s change.
A lost update is a typical problem in transaction processing in SQL. It happens when two queries access and update the same data from a database. This problem can be understood by the below given diagram. Here, A is processing an order for a client for 150 items. He checks from the ITEMS table that there are 300 available items. So he starts placing the order. After few seconds B gets an order for 200 items. He also checks the items table and finds that there are 300 items available. So he also starts placing an order. Meanwhile,