5.4 Concurrency

Concurrency

Concurrency refers to multiple transactions accessing the same database at the same time. In a system which allows concurrency, some kind of control mechanism has to be in place to ensure that concurrent transactions do not interfere with each other.


Three typical problems which can occur due to concurrency are explained here.

a) Lost Update Problem



(To understand the above situation, assume that

  • there is a record R, with a field, say Amt, having value 1000 before time t1.
    • Both transactions A & B fetch this value at t1 and t2 respectively.
    • Transaction A updates the Amt field in R to 800 at time t3.
    • Transaction B updates the Amt field in R to 1200 at time t4.

Thus after time t4, the Amt value in record R has value 1200. Update by Transaction A at time t3 is over-written by the Transaction B at time t4.)

b) Uncommitted Dependency Problem


(To understand the above situation, assume that

  • there is a record R, with a field, say Amt, having value 1000 before time t1.
    • Transaction B fetches this value and updates it to 800 at time t1.
    • Transaction A fetches R with Amt field value 800 at time t2.
    • Transaction B rolls back and its update is undone at time t3. The Amt field takes the initial value 1000 during rollback.

Transaction A continues processing with Amt field value 800 without knowing about B's rollback.)

c) Inconsistent Analysis Problem

Powered by Blogger.