Example 20.6 Preventing the lost update problem using 2PL
A solution to the lost update problem is shown in Figure 20.15. To prevent the lost update
problem occurring, T2 first requests an exclusive lock on balx. It can then proceed to read
the value of balx from the database, increment it by £100, and write the new value back to the database. When T1 starts, it also requests an exclusive lock on balx. However, because the data item balx is currently exclusively locked by T2, the request is not immediately granted and T1
has to wait until the lock is released by T2. This occurs only once the com-mit of T2 has been completed.