Dbms Unit IV - Part 1
Dbms Unit IV - Part 1
Transaction Management
(Part 1)
Dr. D Jinil Persis
Associate Professor,
SCS-HITS
Topics Covered
Transaction Processing – Introduction- Need
for Concurrency control- Desirable properties
of Transaction- Schedule and Recoverability-
Serializability and Schedules Shadow Paging.
Transaction Processing
• Transaction:
– Collection of operations that form a single logical
unit of work
– A unit of program execution that accesses and
possibly updates various data items
– They are initiated by user program which has
Begin transaction
…..
End transaction
ACID – Properties of transaction
• Either all operations in the transaction are reflected in
Atomicity the database or none
Read(X) Write(X)
Partially committed
• after the final statement has been executed
Failed
• after the discovery that normal execution can no longer proceed.
Aborted
• after the transaction has been rolled back and the database restored to its state prior
to the start of the transaction. Two options after it has been aborted:
• Restart the transaction
• It can be done only if no internal logical error
• Kill the transaction
Committed
• after successful completion
State diagram
Shadow copy technique
• For implementing atomicity and durability
• Recovery management component of database
• Make shadow copy of the DB
Need for concurrency
• Concurrent execution of multiple transactions are
allowed in DB
• Transaction has I/O activity and CPU activity.
When one transaction does I/O other can use CPU
– improves throughput
– improves resource utilization
• Transaction may be short or long. Concurrent
execution avoid the waits of short transactions for
long transactions
– reduces waiting time and response time
Example of concurrency
• Let T1 transfer $50 from A to B, and T2 transfer 10% of the balance from A to B.
• An example of a serial schedule in which T1 is followed by T2 :
This is also a serial schedule
This is not a serial schedule
A+B is not preserved
Serializability
• Serializable schedule is the one in which each
transaction preserves database consistency.
• Two type are
– conflict serializability
– view serializability
Conflict serializability
• Let li and lj be two Instructions of transactions Ti and Tj
respectively. Instructions li and lj conflict if and only if
there exists some item Q accessed by both li and lj, and
at least one of these instructions wrote Q.
li = read(Q), lj = read(Q). li and lj don’t conflict.
li = read(Q), lj = write(Q). They conflict.
li = write(Q), lj = read(Q). They conflict
li = write(Q), lj = write(Q). They conflict
• If a schedule S can be transformed into a schedule S’
by a series of swaps of non-conflicting instructions, we
say that S and S’ are conflict equivalent
Conflict removal
Swapping
View Equivalence
Both the schedule result the system in same final state
Schedule S
T2 T1
Example graph
T1
T2
Test for serializability
Steps to test serializability