Monday, 2 April 2018

What is the result of interleaved transactions in database transactions

Result of interleaved transactions in database transactions, Lost Update problem

Question:

Consider the given schedule S1
with transactions T1 and T2; if the value of X at the
beginning of the transactions is 100, what will be the value of X at the end of
the transactions? Also, find the problem with the given schedule.

Transaction T1

Transaction T2

READ X

X:=X - 20

WRITE X

READ X

X:=X - 30

WRITE X

Solution:

The value of X at the end of the
transactions is 70. This value is wrong. From the given schedule, it is very
clear that both transactions are reading the initial value of X as 100, both
calculates the new value to be written, and both writes the new value of X.
here, T1 finishes transaction first and writes it’s new X value 80. Then,
T2 overwrites the value written by T1. Hence, we will see
only one result which is written later.

This problem is called Lost Update problem.

Lost
update problem – it happens when two transactions access
the same resource in an interleaved fashion (i.e., few instructions from T1 and few from T2
and so on) and one of them overwrites the update made by the first.

result produced by two concurrent transactionswhat is the result of two interleaved transactionstransaction exercises in DBMSdatabase transaction and its executionwhat is lost update problem in transactionshow to handle lost update problemdatabase solved exercises
write-write conflict in database transactions