0% found this document useful (0 votes)
46 views16 pages

Database Transactions and Recovery Explained

Uploaded by

miranifarzan0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views16 pages

Database Transactions and Recovery Explained

Uploaded by

miranifarzan0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd

Database

Management
System

Lecture - 42
© Virtual University of Pakistan
Transaction
Generally reflects the activities in
the real world system
One transaction in our exam
system may be computing gpa of a
student, Operations involved…..
More complex transactions
© Virtual University of Pakistan
Consistent State of DB
Consistent state of the database
 Duplicated data does not conflict
 DB properly reflect the real-world
system, i.e. follows the business rules
A transaction should transform database
from one consistent state to another
consistent state, may be inconsistent temp
© Virtual University of Pakistan
Transaction Termination
Two ways a transaction terminates
or ends
It may Commit or Abort
If executed successfully, brings the
database in a new consistent state,
said to be committed
© Virtual University of Pakistan
Transaction Termination
If otherwise, database has to be
brought in prior consistent state
Such transaction is rolled back or
undone
A committed transaction cannot be
undone; compensating transaction
© Virtual University of Pakistan
Transaction Boundaries
Means being and end of Tr
Generally responsibility of
programmer
Otherwise approach varies
from DBMS to DBMS
© Virtual University of Pakistan
ACID Properties
Atomicity: all or none
Consistency: maintains consistency
of the DB
Isolation: Tr should be protected
form the effect of other Trs
Durability: changes by Tr are
permanent © Virtual University of Pakistan
Database Updates
Updates are first made in the
buffers in RAM, then transferred
to database
There may be some delay
between the two
© Virtual University of Pakistan
Database Recovery
If a crash occurs during this delay
then the database is in in consistent
state
On restart DBMS has to identify it
and recover DB into a consistent
state
© Virtual University of Pakistan
Reasons of Failure
Natural disaster
Sabotage
Carelessness
Disk crash
System software errors
Generally, improper shut down of DBMS
© Virtual University of Pakistan
Recovery Techniques
System crashes, buffers are lost
but the disk copy is safe
Need to determine the
transactions that need to redone
or undone
© Virtual University of Pakistan
Log File
Tool used for database recovery
Transaction Record
 <T, starts>
 <T, commits> or <T, aborts>
 Data entries?
© Virtual University of Pakistan
Transaction Operations
Read (X) Operations of DBMS
X=X+5 concern
Write (X) Concern of Recovery
Manager
Y=Y*3
So log file contains
Write (Y)
entries only for write
Commit
operations
© Virtual University of Pakistan
Deferred Updates
Called incremental log with
deferred updates
Updates are not performed until
commit is encountered
Data entries in the log file of the
form <T, X, c>; simplified
© Virtual University of Pakistan
Log File Entries
Read (X) Supposing <T, starts>
X=X+5
Write (X) <T, X, 55>
X = 50
Y = Y * 15 <T, Y, 30>
Write (Y) Y = 10
Commit <T, commit>
© Virtual University of Pakistan
Database
Management
System

Lecture - 42
© Virtual University of Pakistan

You might also like