Non-repeatable reads

A non-repeatable read occurs when, during a transaction, a row is retrieved twice and the row's values are different with every read operation.

Following the previous money transfer example, we can illustrate a non-repeatable read in a similar way:

  • Transaction B reads user 1's account balance as 50.
  • Transaction A updates user 1's account balance from 50 to 100, and commits the transaction.
  • Transaction B reads user 1's account balance again and gets the new value, 100, and then commits the transaction.

The problem here is that transaction B has got a different value in the course of its transaction because it was affected by transaction A's update. This is a problem because transaction B is getting different values within its own transaction. However, in practice, it solves the issue of transferring money between users when they don't exist.

This is why a read committed isolation level, which does not prevent non-repeatable reads but does prevent dirty reads, is the most commonly-used isolation level in practice.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset