CONCURRENCY & RELATED PROBLEMS Database Management System : When more than one transaction is executing at the same time then we say that there is concurrency. Concurrency is Common in client-server architecture where many users are executing their transactions on the same database.

If locking or any other Control technique is not implemented and several users access a database Concurrently, problems may occur if their transactions use the same data at the same time. Concurrency problems include:

  • Lost updates.
  • Uncommitted dependency (dirty read).
  • Inconsistent Read
  • Phantom Phenomenon

Lost Updates

Lost updates occur when two or more transactions select the same row and then update the row based on the value originally selected. Each transaction is unaware of other transactions. The last update overwrites updates made by the other transactions, which results in lost data.

For example, two editors make an electronic copy of the same document. Each editor changes the copy independently and then saves the changed copy, thereby overwriting the original document. The editor who saves the changed copy last overwrites changes made by the first editor. This problem could be avoided if the second editor could not make changes until the first editor had finished.

Another Example

Assume that customer balance (Bal) is 500. And 2 transaction T1 and T2 attempt to update the balance at the same time.


Inconsistent Analysis (Non-repeatable Read)           

inconsistent analysis occurs when a second transaction accesses the same row several times and reads different data each time. Inconsistent analysis is similar to uncommitted dependency in that another transaction is changing the data that a second transaction is reading. However, in inconsistent analysis, the data read by the second transaction was committed by the transaction that made the change. Also, inconsistent analysis involves multiple reads (two or more) of the same row and each time the information is changed by another transaction; thus, the term nonrepeatable read.

For example, an editor reads the same document twice, but between each reading, the writer rewrites the document. When the editor reads the document for the second time, it has changed. The Original read was not repeatable. This problem could be avoided if the editor could read the document only after the writer has finished writing it.


Phantom reads

Phantom reads occur when an insert or delete action is performed against a row that belongs to a range of rows being read by a transaction. The transaction’s first read of the range of rows shows a row that no longer exists in the second or succeeding read, as a result of a deletion by a different transaction. Similarly, as the result of an insert by a different transaction, the transaction’s second or succeeding read shows a row that did not exist in the original read.

For example, an editor makes changes to a document submitted by a writer, but when the changes are incorporated into the master copy of the document by the production department, they find that new unedited material has been added to the document by the author. This problem could be avoided if no one Could add new material to the document until the editor and production department finish working with the original document.