Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Serializability

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

***Write Short note on :

• concept of view of serializability


• dirty read anomaly
• lost update anomaly
• conflict Equivalent

1.View Serializability in DBMS:

In this article, we will learn about View Serializability in DBMS.

• A schedule is view serializable when it is view equivalent to a serial schedule.


• All conflict serializable schedules are view serializable.
• The view serializable which is not a conflict serializable contains blind write

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

• Suppose in schedule S1, if transaction Tm is reading A which is updated by


transaction Tn then in S2 also, Tm should read A which is updated by Tn.
• The two schedules are not view equal because, in S1,transaction T3 is reading A
updated by transaction T2 and in S2, transaction T3 is reading A which is updated by
transaction T1.

3.Final Write

• A final write must be the same in both the schedules.


• Suppose in schedule S1, if a transaction T1 updates A in the last, then in S2 final
write operation should also be done by transaction T1.
• The two schedules is view equal because Final write operation in S1 is done by T3
and in S2 also the final write operation is done by T3.

As per the concept of Conflict-Serializability, We can say that a schedule is Conflict-


Serializable (means serial and consistent) if its corresponding precedence graph does not
have any loop/cycle.
But, what if a schedule’s precedence graph contains a cycle/loop and is giving consistent
result/accurate result as a conflict serializable schedule is giving
So, to address such cases we brought the concept of View-Serializability because we did not
want to confine the concept serializability only to Conflict-Serializability.
Checking Whether a Schedule is View Serializable Or Not-
• Check whether the given schedule is conflict serializable or not.
• Check if there exists any blind write operation.
• In this method, try finding a view equivalent serial schedule.

Example:

Schedule S1

• Step 1: Final updation on data items

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.

• Step 2: Initial Read

The initial read operation in S is done by T1 and in S1, it is also done by T1.

• Step 3: Final Write

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

2. Dirty Read Anomaly

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

‘write’ statement and with commit command, it completes its execution.


Then transaction T1 again performs read operation on some data Z and get failed. This

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

written by transaction T2 is considered to be wrong.

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.

3.Lost update Anomaly

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

Explain with Example


Consider two schedules “A” and “Y

” which are not conflict equivalent as given under.

You might also like