Transactions Lecture 2
Transactions Lecture 2
Schedules
Schedule – a sequences of instructions that specify the chronological
order in which instructions of concurrent transactions are executed
a schedule for a set of transactions must consist of all instructions of those
transactions
must preserve the order in which the instructions appear in each individual
transaction.
A transaction that successfully completes its execution will have a commit
instructions as the last statement
by default transaction assumed to execute commit instruction as its last step
A transaction that fails to successfully complete its execution will have an
abort instruction as the last statement
Schedule 1
Let T1 transfer $50 from A to B, and T2 transfer 10% of the balance from A to B.
A serial schedule in which T1 is followed by T2 :
Before transaction: A=500
B=600 Total=1100
A=500 After Transaction : A=405
A=450 B=695 Total=1100
B=600
B=650
A=450
temp=45
A=405
B=650
B=695
Before transaction: A=500
Let T1 and T2 be the transactions defined previously. The following schedule is not a
serial schedule, but it is equivalent to Schedule 1.
Before transaction: A=500
B=600 Total=1100
A=500
After Transaction : A=405
A=450 B=695 Total=1100
A=450
Temp=
45
B=600 A=405
B=650
B=650
B=695
Thus, there are three types of conflicts: – Read-Write conflicts (RW) – Write-
Read conflicts (WR) – Write-Write conflicts (WW)
Anomalies with Interleaved
Execution
Temporary Update Problem/ Dirty Read (Write-Read
Conflict)
Lost Update Problem (Write-Write Conflict)
Unrepeatable Read Problem (RW Conflicts):
Phantom Read Problem
Incorrect Summary Problem
Anomalies with Interleaved
Execution
Temporary Update Problem (WR Conflicts, “dirty reads”):
Temporary update or dirty read problem occurs when one transaction updates
an item and fails. But the updated item is used by another transaction before
the item is changed or reverted back to its last value.
A=10 A=10
A=10
A=10-2=8 A=8
Write=8-8=0
B=15
B=15-2=13
Unrepeatable Reads (RW Conflicts): The
unrepeatable read problem occurs when two or
more read operations of the same transaction
read different values of the same variable.
Lost update/ Overwriting Uncommitted Data (WW Conflicts):
In the lost update problem, an update done to a data item by a
transaction is lost as it is overwritten by the update done by another
transaction.
Phantom read: