Why Concurrency Control is Needed in Database?

To make system efficient and save time, it is required to execute more than one transaction at the same time. But concurrency leads several problems. The three problems associated with concurrency  are  as  follows:

1. The Lost Update Problem

If any transaction Tj updates any variable v at time t without knowing the value of v at time t then this may leads to lost update problem. Consider the transactions shown in Figure 8.3.

At time t1 and t2, transactions ti and tj reads variable v respectively and get some value of v. At time t3, ti updates v but, at t4, tj also updates v (old value of v) without looking the new value of v (updated by ti). So, updation made by ti at t3 is lost at t4 because tj overwrites it.

2. The Uncommitted Dependency Problem

This problem arises if any transaction tj updates any variable v and allows retrieval or updation of v by any other transaction but tj rolled back due to failure. Consider the transactions shown  in  Figure  8.4.

At time t1, transaction tj, updates variable v which is read or updated by Ti at time t2. Suppose at time t3, tj is rollbacked due to any reason then result produced by Ti is wrong because it is based on false assumption.

3. The Inconsistent Analysis Problem

Consider the transactions  shown in Figure  8.5.

The transaction Ti reads variable a and b at time t1 and t2 respectively. But at time t3, Tj updates value of a from 10 to 50 and commits at t4 that makes changes permanent. So, addition of a and b at time t5 gives wrong result. This leads inconsistency in database because of inconsistent analysis by Ti.

Source: Gupta Satinder Bal, Mittal Aditya (2017), Introduction to Basic Database Management System, 2nd Edition-University Science Press (2017)

Leave a Reply

Your email address will not be published. Required fields are marked *