Professional Documents
Culture Documents
Transaction
Transaction
MANAGEMENT
CONCEPT OF A TRANSACTION
single
logical
unit of
work
read(A)
A := A – 50
write(A) Operations
Transaction
read(B)
B := B + 50
write(B)
TRANSACTION STATES
Partially
committed
commited
Active Terminated
Failed Aborted
PROPERTIES OF TRANSACTION(ACID)
➢ Atomicity
➢ Consistency
➢ Isolation
➢ Durability
ATOMICITY
A := A – 50
➢ Either execute 0% or 100%. write(A)
FAIL
read(B)
B := B + 50
➢ In this transaction, if Rs.50 write(B)
is deducted from account A
then it must be added to 100%
account B
CONSISTENCY
A=500,B=500
➢ Transaction must A+B=1000
remain in a consistent
read(A)
state after any
transaction. A := A – 50
write(A)
read(B)
➢ In this transaction,
total of A and B must B := B + 50
remain same before write(B)
and after the execution
of transaction A=450,B=550
A+B=1000
ISOLATION
➢ Changes occurring in a
particular transaction
will not be visible to any read(A)
other transaction until it
has been committed A := A – 50
write(A)
➢ In this transaction, once
read(B)
transaction starts from
first step(step1) it’s result B := B + 50
should not be access by
any other transaction write(B)
until last step(step6) is
completed
DURABILITY
write(A)
Begin Transaction
(details of the transaction)
Commit
TRANSACTION TO TRANSFER10 PERCENT OF
BALANCE FROM ACCOUNT A TO ACCOUNT B
read(A)
Temp = A *0.1
A = A – Temp
write(A)
read(B)
B = B + Temp
write(B)
SCHEDULE
Schedule – a sequences of instructions that
specify the chronological order in which
instructions of concurrent transactions are
executed.
EXAMPLE OF SCHEDULE
T1 T2 A=B=1000
read(A) read(1000)
A := A – 50 A := 1000 – 50
Write (A) Write (950)
read(B) read(1000)
B := B + 50 B := 1000+ 50
Write (B) Write (1050)
Commit read(A) Commit
Temp = A *0.1 read(950)
A = A – Temp Temp = 950*0.1
write(A) A = 950 – 95
read(B) Write(855)
B = B + Temp read(1050)
write(B) B = 1050+95
commit write(1145)
‘ commit
EXAMPLE OF SCHEDULE
T1 T2 A=B=1000
read(A) read(1000)
Temp = A *0.1 Temp = 1000*0.1
A = A – Temp A = 1000 – 100
write(A) Write(900)
read(B) read(1000)
B = B + Temp B = 1000+100
write(B) write(1100)
commit Commit
read(A) ‘ read(900)
A := A – 50 A := 900 – 50
Write (A) Write (850)
read(B) read(1100)
B := B + 50 B := 1100+ 50
Write (B) Write (1150)
Commit Commit
SERIAL SCHEDULE
T1 T2
A SERIAL SCHEDULE 2 IN WHICH T2 IS
FOLLOWED BY T1
T2 T1
CONCURRENT SCHEDULE
T1 T2
EQUIVALENT SCHEDULE
If two schedule produce the same result after
execution , they are said to be equivalent
schedule.
SERIALIZABILITY
A schedule is serializable if it is equivalent to a
serial schedule.
In serial schedules , only one transaction is
allowed to execute at a time.i.e.no concurrency
In serializable schedules , multiple transactions
can execute simultaneously . i.e. concurrency is
allowed
SERIALIZABILITY
T1 T2
T1 T2
read(A)
R(A)
A := A – 50 R(A)
Write (A)
read(B) W(A)
B := B + 50
Write (B) W(A)
Commit
read(A)
Temp = A *0.1
A = A – Temp
write(A)
read(B)
B = B + Temp T1 T2
write(B)
commit
T1 → T2
OR
T1 T2
T2 → T1
SERIALIZABILITY
Types
1. Conflict serializability
2. View serializability
R(A)
W(A)
W(A)
W(A)
EXAMPLE 3…
T1 T2 T3
R(A)
W(A)
T1 T2
LOOP
W(A)
Non Conflict Serializable
W(A) T3
Serializable?
VIEW SERIALIZABILITY
100 S S’ 100
T1 T2 T3 T1 T2 T3
R(A) R(A)
T2
T1
Serializable
T3
T1 T2
R(X)
W(X)
R(X)
W(X)
R(Y)
W(Y)
R(Y)
W(Y)