DEV Community

Ankita
Ankita

Posted on

concurrency problems

When multiple transactions execute concurrently in an uncontrolled or unrestricted manner, then it might lead to several problems.

Such problems are called as concurrency problems.

  1. Dirty Read Problem
  2. Unrepeatable Read Problem
  3. Lost Update Problem
  4. Phantom Read Problem

Dirty Read Problem

Reading the data written by an uncommitted transaction is called as dirty read.

This read is called as dirty read because there is always a chance that the uncommitted transaction might roll back later.Thus, uncommitted transaction might make other transactions read a value that does not even exist.This leads to inconsistency of the database.

Dirty read does not lead to inconsistency always.It becomes problematic only when the uncommitted transaction fails and roll backs later due to some reason.

Image description

Unrepeatable Read Problem

This problem occurs when a transaction read different values of the same variable in its different read operations even when it has not updated its value.

Image description

Lost Update Problem

This problem occurs when multiple transactions execute concurrently and updates from one or more transactions get lost.

This problem occurs whenever there is a write-write conflict.In write-write conflict, there are two writes one by each transaction on the same data item without any read in the middle.

Image description

Phantom Read Problem

This problem occurs when a transaction reads some variable from the buffer and when it reads the same variable later, it finds that the variable does not exist.

Image description

Top comments (0)