Showing posts with label Transaction Management. Show all posts
Showing posts with label Transaction Management. Show all posts

Sunday, April 15, 2018

Why do we need a recoverable schedule

Why do we need a recoverable schedule?


Why do we need a recoverable schedule?
Unrecoverable schedules lead to inconsistent database state. Hence, we need only recoverable schedules to safeguard consistency in concurrent execution of transactions.
T1
T2
R(x)
W(x)


R(y)
W(y)


R(x)
W(x)



To explain this, let us use the example schedule given above. Let us assume that the transaction T2 commits before T1 commits. Also assume that, the transaction T1 has failed due to some reasons. In that case, T1 has to be aborted. If T1 has to be aborted then the transactions that have consumed data that was written by T1 must also be aborted. In our example, we need T2 must also be aborted (cascading abort). As T2 has already committed, aborting T2 is not possible. Now, this schedule is unrecoverable. This leads to inconsistent database state. Hence we need recoverable schedules.


**********










Why recoverable schedules?
what is the purpose of recoverable schedules?
dirty reads in concurrent schedules
what is unrecoverable schedule

Recoverable schedules in database transaction

Recoverable schedules in database transaction


Recoverable schedules

A schedule is recoverable if every transaction in that schedule commits only after all the transactions whose changes they read have committed.

A schedule where, for each pair of transactions Ti and Tj, if Tj reads a data item previously written by Ti, then the commit operation of Ti precedes the commit operation of Tj.

For example, assume a schedule S with two transactions T1, and T2. If T2 consumes a data item written by T1 then T1 must commit before T2. If this happens then the schedule S is said to be recoverable schedule.

If a schedule should be recoverable, then there shouldn’t be any dirty reads [reading of uncommitted data].


Example:
Is the following transaction is recoverable or not?
Instruction
T1
T2
1
2
3
4
5
6
R(x)

W(y)

Commit

R(x)

W(y)

Commit

This schedule is recoverable because there are no dirty reads. Here, T1 commits before T2 but T2 is not consuming any data that is written by T1. Hence, this schedule is recoverable. Also, the order of commit is not an issue as neither T1 nor T2 has consumed data written by the other transactions. 

***********







Recoverable schedules in concurrent schedules
what is recoverable schedule
define recoverable schedules
recoverable schedules example
how to identify a recoverable schedule
check for recoverability in concurrent schedules

Monday, April 2, 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 transactions
what is the result of two interleaved transactions
transaction exercises in DBMS
database transaction and its execution
what is lost update problem in transactions
how to handle lost update problem
database solved exercises
write-write conflict in database transactions

Featured Content

Multiple choice questions in Natural Language Processing Home

MCQ in Natural Language Processing, Quiz questions with answers in NLP, Top interview questions in NLP with answers Multiple Choice Que...

All time most popular contents

data recovery