Ch2-TransactionConcepts (1)
Ch2-TransactionConcepts (1)
Transaction Concepts
Agenda
2.1 Transaction, properties of transaction, states of transactions
2.2 Concurrent execution of transactions and conflicting
operations
2.3 Schedules, types of schedules, concept of serializability,
precedence graph for serializability
Transaction
A sequence of operations that must be treated as an
undivided unit
Operations read and write
read(x)-Access resource x without modifying it.
write(x)-Modify resource x.
Transaction must be either committed or aborted
Example
A transfer between account. Money should be transferred or
withdrawn from account.
ACID Properties
Atomicity:
We mean that either the entire transaction takes place at once or
doesn’t happen at all. There is no midway i.e. transactions do not
occur partially.
Each transaction is considered as one unit and either runs to
completion or is not executed at all.
It involves the following two operations.
Abort: If a transaction aborts, changes made to the database are
not visible.
Commit: If a transaction commits, changes made are visible.
Atomicity is also known as the ‘All or nothing rule’.
Consider the following transaction T consisting of T1 and T2:
Transfer of 100 from account X to account Y.
Suppose T has been executed till Read (Y) and then T’’ starts.
As a result, interleaving of operations takes place due to which T’’ reads the
correct value of X but the incorrect value of Y and sum computed by
T’’: (X+Y = 50, 000+500=50, 500)
is thus not consistent with the sum at end of the transaction:
T: (X+Y = 50, 000 + 450 = 50, 450).
This results in database inconsistency, due to a loss of 50 units. Hence,
transactions must take place in isolation and changes should be visible only after
they have been made to the main memory.
Durability
A= 1000,B=1000,C=1000
Transaction 1 Transaction 2
Lost Update Problem
Lost Update Problem
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.
A lost update problem occurs due to the update of the same record
by two different transactions at the same time. In simple words,
when two transactions are updating the same record at the same
time in a DBMS then a lost update problem occurs.
Two transactions T1 and T2 read, modify, write to the same data
item in an interleaved fashion for which an incorrect value is
stored in X . T2 reads the value of X before T1 changes it hence the
updated value resulting from T1 is lost.
Unrepeatable Read Problem