Serializability
Serializability
Serializability
View Equivalent-Two view equivalent schedules S1 and S2 should satisfy the following
conditions:
1.Initial Read
• The initial read of both the schedules must be in the same transaction.
• Suppose two schedule S1 and S2. In schedule S1, if a transaction T1 is reading the
data item A, then in S2, transaction T1 should also read A.
• The two schedules S1 and S2 are view equivalent because Initial read operation in S1
is done by T1 and in S2 also it is done by T1.
2.Updated Read
3.Final Write
Example:
Schedule S1
In both schedules S and S1, there is no read except the initial read that’s why we don’t need
to check that condition.
The initial read operation in S is done by T1 and in S1, it is also done by T1.
The final write operation in S is done by T3 and in S1, it is also done by T3. So, S and S1 are
view Equivalent.
The first schedule S1 satisfies all three conditions, so we don’t need to check another
schedule.Hence, view equivalent serial schedule is T1 → T2 → T3
When a transaction is allowed to read a row that has been modified by an another
transaction which is not committed yet that time Dirty Reads occurred. It is mainly occurred
because of multiple transaction at a time which is not committed.
According to the atomicity property of the transaction, the transaction rolled back and
started from the begging i.e. the old or raw value of that data. But the other transaction
which is already get completed by reading the old updated value of data is not
considered an incorrect transaction as its data is considered as wrong data or dirty
read. This whole scenario is called the dirty read problem.
T1 T2
Read(Y)
Update Y=Y+1000
Write(Y)
Read(Y)
Update Y=Y+500
Write(Y)
commit
Read(Z) // Failed
Write(Z)
Let two transactions T1 is execution and read a data Y from the database and then
update the data by adding 1000 to data and then write statement is executed (but the
transaction is not finished). Then another transaction T2 comes in the action and it read
the updated value of Y and performs subtracting 500 from Y and then executes the
failure will abort the transaction T1 and then the transaction T2 which has already been
completed by reading the value of updated X which was the part of an aborted
transaction, is now not a stable database transaction. Hence the data returned or
One of the most common problems that occur while running concurrent transactions is the
Dirty Read problem. A dirty read occurs when one transaction is permitted to read data that
is being modified by another transaction that is running concurrently but which has not yet
committed itself.If the transaction that modifies the data commits itself, the dirty read
problem doesn’t occur. However if the transaction that modifies the data is rolled back after
the other transaction has read the data, the latter transaction has dirty data that doesn’t
actually exist.
A lost update problem occurs in concurrent transactions, when two transactions try to read
and update the same column on the same row within a database at the same time.
Suppose 1st transaction read any column value and process the update request while 2nd
transaction began shortly afterward which read the same value and update the value
immediately, later 1st transaction completes update process. In this way the updated value
by 2nd transaction is lost as it is overwritten by 1st transaction.
Lets understand this with the help of above diagram, as you can see the 1st transaction read
an available balance as 5000 and deduct an amount 2000 from available balance and
process the update request while 2nd transaction immediately read an available balance as
5000 and deduct amount 1000 and quickly update the balance amount that is 5000 – 1000 =
4000, later 1st transaction completes the update request by updating the balance amount
as 5000 – 2000 that is 3000, so in this way the 1st transaction overwrites the updated value
of 2nd transaction.
Now the point is that, after the execution of both transactions the actual balance should be
2000, as 1st transaction deducts the amount 2000 and 2nd transaction deducts 1000 from
available balance 5000 so the overall available balance should be 5000 – (1000 + 2000) =
2000, but as a final result we get the overall available balance as 3000, means we lost the
2nd transaction update and this is called as Lost update problem.
4.Conflict Equivalent Schedule
In the conflict equivalent, one schedule can be converted into another schedule by swapping
just non-conflicting operations.
Before to learn conflict equivalent schedule you must know about
• Conflict and non-conflict pairs.
• Swapping of pairs
Remind
• Non-conflict pairs are always replaceable in schedule
• Conflict pairs are never be replaceable in schedule