ADBMS Chapter 2
ADBMS Chapter 2
Database System Concepts - 5th Edition, Sep 12, 2006. 15.3 ©Silberschatz, Korth and Sudarshan
Database State
Database System Concepts - 5th Edition, Sep 12, 2006. 15.4 ©Silberschatz, Korth and Sudarshan
Although a SELECT query in SQL does not
Database System Concepts - 5th Edition, Sep 12, 2006. 15.5 ©Silberschatz, Korth and Sudarshan
Transaction Concept
A transaction can have one of two outcomes:
Database System Concepts - 5th Edition, Sep 12, 2006. 15.6 ©Silberschatz, Korth and Sudarshan
Concurrent Executions-advantages
Database System Concepts - 5th Edition, Sep 12, 2006. 15.7 ©Silberschatz, Korth and Sudarshan
Database Concurrency Control
Concurrency Control : A process of managing simultaneous
operation in a database with out having them interfere with one
another.
Need of concurrency
Enables many users to access shared data concurrently.
Similar objective with multi-user computer system
Improve throughput- (the amount of work accomplished in a given
time interval)
Purpose of Concurrency Control
To enforce Isolation (through mutual exclusion) among
conflicting transactions.
To preserve database consistency through consistency
preserving execution of transactions.
Concurrency Control Schemes – mechanisms to achieve isolation.
that is, to control the interaction among the concurrent transactions in order to
prevent them from destroying the consistency of the database
Database System Concepts - 5th Edition, Sep 12, 2006. 15.8 ©Silberschatz, Korth and Sudarshan
Potential Problems Caused By Concurrency
9
Database System Concepts - 5 Edition, Sep 12, 2006.
th
15.9 ©Silberschatz, Korth and Sudarshan
Lost Update problem - Example
Assume that you have a product whose current
quantity value is 35.
Also assume that two concurrent transactions, T1 and
T2, occur that update the quantity value for some item in
the database.
The transactions are as below:
Transaction Computation
T1: Buy 100 units quantity =quantity +100
T2 : Sell 30 units quantiity=qunatitiy-30
Database System Concepts - 5th Edition, Sep 12, 2006. 15.10 ©Silberschatz, Korth and Sudarshan
Following table shows the serial execution of
those transactions under normal circumstances,
yielding the correct answer quantity = 105.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.11 ©Silberschatz, Korth and Sudarshan
If a transaction is able to read a product’s quantity
value from the table before a previous transaction
(using the same product) has been committed.
The sequence depicted below shows how the lost
update problem can arise.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.12 ©Silberschatz, Korth and Sudarshan
Uncommitted Data - Example
Assume that you have a product whose current quantity
value is 35.
Also assume that two concurrent transactions, T1 and T2,
occur that update the quantity value for some item in the
database.
T1 is forced to roll back due to an error. T1 transaction is
rolled back to eliminate the addition of the 100 units. Because
T2 subtracts 30 from the original 35 units, the correct answer
should be 5.
The transactions are as below:
Transaction Computation
T1: Buy 100 units quantity =quantity +100
T2 : Sell 30 units quantiity=qunatitiy-30
Database System Concepts - 5th Edition, Sep 12, 2006. 15.13 ©Silberschatz, Korth and Sudarshan
Following table shows the serial execution of
those transactions under normal circumstances,
yielding the correct answer quantity = 5.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.14 ©Silberschatz, Korth and Sudarshan
Following table shows how the uncommitted data
problem can arise when the ROLLBACK is completed
after T2 has begun its execution.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.15 ©Silberschatz, Korth and Sudarshan
Example : Inconsistence Analysis Problem
T1 T2
Sum 0
If one transaction is calculating
Read(A)
an aggregate summary function sumsum+A
on a number of records while ………..
updated. sumsum+Y
Read(Y)
YY+N
Write(Y)
1. Active state
2. Partially committed state
3. Committed state
4. Failed state
5. Terminated State
Database System Concepts - 5th Edition, Sep 12, 2006. 15.18 ©Silberschatz, Korth and Sudarshan
State transition diagram illustrating the
states for transaction execution
Database System Concepts - 5th Edition, Sep 12, 2006. 15.19 ©Silberschatz, Korth and Sudarshan
Transaction State
1. A transaction goes into an active state immediately after
it starts execution where it can issue READ or WRITE
operations.
2. When the transaction ends, it moves to the partially
committed state where certain recovery protocols
ensures that a system failure will not result in an inability
to record the changes of the transaction permanently.
(Changes are recorded in TRANSACTION LOG)
a. If this check is successful the transaction enters into
a commit point and enters the committed state. If
so, all its changes must be recorded permanently in
the database.
b. If this check fails, it goes to the failed state.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.20 ©Silberschatz, Korth and Sudarshan
Transaction State
Database System Concepts - 5th Edition, Sep 12, 2006. 15.22 ©Silberschatz, Korth and Sudarshan
ACID Properties
Atomicity
Database System Concepts - 5th Edition, Sep 12, 2006. 15.23 ©Silberschatz, Korth and Sudarshan
ACID Properties
Consistency
Database System Concepts - 5th Edition, Sep 12, 2006. 15.25 ©Silberschatz, Korth and Sudarshan
ACID Properties
Durability
Database System Concepts - 5th Edition, Sep 12, 2006. 15.26 ©Silberschatz, Korth and Sudarshan
When executing multiple transactions, the DBMS must
Durability requirement — once the user has been notified that the transaction has
completed (i.e., the transfer of the $50 has taken place), the updates to the database by
the transaction must persist even if there are software or hardware failures.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.28 ©Silberschatz, Korth and Sudarshan
Example of Fund Transfer (Cont.)
Transaction to transfer $50 from account A to account B:
1. read(A)
2. A := A – 50
3. write(A)
4. read(B)
5. B := B + 50
6. write(B)
Consistency requirement in above example:
the sum of A and B is unchanged by the execution of the
transaction
A transaction must see a consistent database.
During transaction execution the database may be temporarily
inconsistent.
When the transaction completes successfully the database must be
consistent.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.29 ©Silberschatz, Korth and Sudarshan
Example of Fund Transfer (Cont.)
Isolation requirement — if between steps 3 and 6, another transaction T2 is
allowed to access the partially updated database, it will see an inconsistent
database (the sum A + B will be less than it should be).
T1 T2
1. read(A)
2. A := A – 50
3. write(A)
read(A), read(B), print(A+B)
4. read(B)
5. B := B + 50
6. write(B
Isolation can be ensured trivially by running transactions serially
that is, one after the other.
However, executing multiple transactions concurrently has significant
benefits.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.30 ©Silberschatz, Korth and Sudarshan
Transaction Management with SQL
The (ANSI) has defined standards that govern SQL
database transactions.
Transaction support is provided by two SQL statements:
COMMIT and ROLLBACK.
A COMMIT statement
A ROLLBACK statement
Database System Concepts - 5th Edition, Sep 12, 2006. 15.31 ©Silberschatz, Korth and Sudarshan
Transaction Log
A DBMS uses a transaction log to keep track of all
transactions that update the database.
The information stored in this log is used by the DBMS for a
recovery requirement triggered by a ROLLBACK statement,
a program’s abnormal termination, or a system failure such
as a network discrepancy or a disk crash.
After a server failure, for example, Oracle automatically rolls
back uncommitted transactions and rolls forward transactions
that were committed but not yet written to the physical
database.
This behavior is required for transactional correctness and is
typical of any transactional DBMS.
Using a transaction log increases the processing overhead of
a DBMS; but have the ability to restore a corrupted database.
.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.32 ©Silberschatz, Korth and Sudarshan
Transaction Log
While the DBMS executes transactions that modify the
database, it also automatically updates the transaction
log. The transaction log stores:
A record for the beginning of the transaction.
For each transaction component (SQL statement):
The type of operation being performed (update,
delete, insert).
The names of the objects affected by the transaction
(the name of the table).
The “before” and “after” values for the fields being
updated.
Pointers to the previous and next transaction log
entries for the same transaction.
The ending (COMMIT) of15.33
the transaction.
Database System Concepts - 5th Edition, Sep 12, 2006. ©Silberschatz, Korth and Sudarshan
The Scheduler
As long as two transactions, T1 and T2, access unrelated
data, there is no conflict and the order of execution is
irrelevant to the final outcome.
But if the transactions operate on related (or the same)
data, conflict is possible among the transaction
components and the selection of one execution order
over another might have some undesirable
consequences.
So how is the correct order determined, and who
determines that order?
The DBMS handles that tricky assignment by using a
built-in scheduler.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.34 ©Silberschatz, Korth and Sudarshan
The Scheduler
Database System Concepts - 5th Edition, Sep 12, 2006. 15.35 ©Silberschatz, Korth and Sudarshan
Schedules
Schedule – a sequences of instructions that specify the
chronological order in which instructions of concurrent
transactions are executed.
When transactions are executing concurrently in an interleaved
fashion, the order of execution of operations from the various
transactions, forms what is known as a transaction schedule (or
history).
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
A transaction that fails to successfully complete its execution will
have an abort instruction as the last statement
Database System Concepts - 5th Edition, Sep 12, 2006. 15.36 ©Silberschatz, Korth and Sudarshan
Serial & Non-Serial Schedules
Serial schedule:
Database System Concepts - 5th Edition, Sep 12, 2006. 15.37 ©Silberschatz, Korth and Sudarshan
Serial & Non-Serial Schedules
Non-Serial schedule:
Database System Concepts - 5th Edition, Sep 12, 2006. 15.38 ©Silberschatz, Korth and Sudarshan
Schedule 1
Let T transfer $50 from A to B, and T transfer 10% of the
1 2
balance from A to B.
A serial schedule in which T1 is followed by T2 :
Database System Concepts - 5th Edition, Sep 12, 2006. 15.39 ©Silberschatz, Korth and Sudarshan
Schedule 2
• A serial schedule where T2 is followed by T1
Database System Concepts - 5th Edition, Sep 12, 2006. 15.40 ©Silberschatz, Korth and Sudarshan
Serial & Non-Serial Schedules
Database System Concepts - 5th Edition, Sep 12, 2006. 15.41 ©Silberschatz, Korth and Sudarshan
Schedule 3(Non Serial)
Let T and T be the transactions defined previously. The following
1 2
schedule is not a serial schedule, but it is equivalent to Schedule 1.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.42 ©Silberschatz, Korth and Sudarshan
Schedule 4
The following concurrent schedule (nonserial) does not
preserve the value of (A + B ).
Database System Concepts - 5th Edition, Sep 12, 2006. 15.43 ©Silberschatz, Korth and Sudarshan
Serializable Schedule
The scheduler interleaves the execution of database
operations to ensure serializability and isolation of
transactions.
A serializable schedule is a schedule of a transaction’s
operations in which the interleaved execution of the
transactions (T1, T2, T3, etc.) yields the same results as
if the transactions were executed in serial order (one after
another).
The scheduler also makes sure that the computer’s central
processing unit (CPU) and storage systems are used efficiently.
Additionally, the scheduler facilitates data isolation to ensure that
two transactions do not update the same data element at the
same time.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.44 ©Silberschatz, Korth and Sudarshan
The objectives of Serializability:
To determine which of the non serial schedules always give a correct
result and which may give erroneous result.
The concept used to characterize schedules in this manner is that of
serializability of a schedule.
To prevent inconsistency from transactions interfering with one
other, it is essential to guarantee serializability of concurrent
transactions.
A schedule S of n transactions is serializable if it is
equivalent to some serial schedule of the same n
transactions.
Being serializable implies that the schedule is a correct schedule.
It will leave the database in a consistent state.
The interleaving is appropriate and will result in a state as if the
transactions were serially executed, yet will achieve efficiency due
to concurrent execution.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.45 ©Silberschatz, Korth and Sudarshan
Conflict Serializability
Two schedules are said to be conflict equivalent if the order of
any two conflicting operations is the same in both schedules.
Two operations are said to conflict
Database System Concepts - 5th Edition, Sep 12, 2006. 15.46 ©Silberschatz, Korth and Sudarshan
Conflict Serializability
Database System Concepts - 5th Edition, Sep 12, 2006. 15.47 ©Silberschatz, Korth and Sudarshan
Conflict Serializability (Cont.)
Schedule 1 can be transformed into Schedule 2, a serial
schedule where T2 follows T1, by series of swaps of non-
conflicting instructions.
Therefore Schedule 1 is conflict serializable.
Schedule 1 Schedule 2
Database System Concepts - 5th Edition, Sep 12, 2006. 15.48 ©Silberschatz, Korth and Sudarshan
Characterizing Schedules based on
Recoverability
Recoverable schedule:
Database System Concepts - 5th Edition, Sep 12, 2006. 15.49 ©Silberschatz, Korth and Sudarshan
Example: Unrecoverable schedule
Time T1 T2
T1 begin_transaction
T2 read(balx)
T3 balx=balx+100 begin_transaction
T4 write(balx) read(balx) .. (read undone)
T5 balx=balx*10
T6 write(balx)
T7 read(baly)
T8 baly=baly*10
T9 write(baly)
T10 commit
T11 read(baly)
T12 baly=baly-100
T13 write(baly)
T14 rollback
Database System Concepts - 5th Edition, Sep 12, 2006. 15.50 ©Silberschatz, Korth and Sudarshan
Concurrency Control
A policy in which only one transaction can execute at a
Database System Concepts - 5th Edition, Sep 12, 2006. 15.51 ©Silberschatz, Korth and Sudarshan
Objective Of a Concurrency Control Protocol
Database System Concepts - 5th Edition, Sep 12, 2006. 15.52 ©Silberschatz, Korth and Sudarshan
Concurrency Control Techniques
Most of these techniques ensure serializability of schedules using
protocols that guarantee serializability.
The two main concurrency control techniques:
Locking
Timestamping
Locking
A procedure to control concurrent access to data. When one
transaction is accessing the database, the lock may deny access to
other transactions .
A lock is a control placed in the database to reserve data so that only
one database user may update it.
When data is locked, no other database session can update the data
until the lock is released. Any other session that attempts to update
locked data will be placed in a lock wait state.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.53 ©Silberschatz, Korth and Sudarshan
Concurrency Control with Locking
Methods
A transaction acquires a lock prior to data access;
The lock is released (unlocked) when the transaction is
completed so that another transaction can lock the data item for
its exclusive use.
The use of locks based on the assumption that conflict between
transactions is likely to occur is often referred to as pessimistic
locking.
Most multiuser DBMSs automatically initiate and enforce locking
procedures. All lock information is managed by a lock manager,
which is responsible for assigning and policing the locks used by
the transactions
Lock Granularity: indicates the level of lock use. Locking can
take place at the following levels: database, table, page, row, or
even field (attribute).
Database System Concepts - 5th Edition, Sep 12, 2006. 15.54 ©Silberschatz, Korth and Sudarshan
Database Lock
Database System Concepts - 5th Edition, Sep 12, 2006. 15.55 ©Silberschatz, Korth and Sudarshan
Database Lock
In a database-level lock, the entire database is locked,
Database System Concepts - 5th Edition, Sep 12, 2006. 15.56 ©Silberschatz, Korth and Sudarshan
Table Level
Database System Concepts - 5th Edition, Sep 12, 2006. 15.57 ©Silberschatz, Korth and Sudarshan
Table Level
In a table-level lock, the entire table is locked, preventing access
be locked.
same table & when the transactions would not interfere with each
other this lock is not suitable for multiuser DBMSs.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.58 ©Silberschatz, Korth and Sudarshan
Page Level
Database System Concepts - 5th Edition, Sep 12, 2006. 15.59 ©Silberschatz, Korth and Sudarshan
Page level
In a page-level lock, the DBMS will lock an entire diskpage.
A table can span several pages, and a page can contain several
Database System Concepts - 5th Edition, Sep 12, 2006. 15.61 ©Silberschatz, Korth and Sudarshan
Row level
A row-level lock is much less restrictive.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.62 ©Silberschatz, Korth and Sudarshan
Field level lock
Database System Concepts - 5th Edition, Sep 12, 2006. 15.63 ©Silberschatz, Korth and Sudarshan
Lock Types
Binary
Shared/exclusive.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.64 ©Silberschatz, Korth and Sudarshan
Binary Lock
A binary lock has only two states: locked (1) or unlocked (0).
Every transaction requires a lock and unlock operation
for each data item that is accessed.
Such operations are automatically managed and
scheduled by the DBMS; the user does not need to be
concerned about locking or unlocking data items.
If the end user wants to override the default, the LOCK
TABLE and other SQL commands are available for that
purpose.
Binary locks are now considered too restrictive to yield
optimal concurrency conditions. For example, the DBMS
will not allow two transactions to read the same database
object even though neither transaction updates the database,
and therefore, no concurrency problems can occur.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.65 ©Silberschatz, Korth and Sudarshan
Shared/Exclusive Locks
the lock.
conflict exists.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.67 ©Silberschatz, Korth and Sudarshan
Shared/Exclusive Locks
Shared locks allow several Read transactions to read the same data
The exclusive lock is granted if and only if no other locks are held
on the data item. If a shared or exclusive lock is already held on X
by T1, an exclusive lock cannot be granted to T2 and T2 must wait
to begin until T1 commits.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.69 ©Silberschatz, Korth and Sudarshan
Two-Phase Locking to Ensure
Serializability
Two-phase locking defines how transactions acquire
Database System Concepts - 5th Edition, Sep 12, 2006. 15.71 ©Silberschatz, Korth and Sudarshan
Two Phase Locking
The two-phase locking protocol is governed by the
following rules:
same transaction.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.72 ©Silberschatz, Korth and Sudarshan
Two phase locking
Database System Concepts - 5th Edition, Sep 12, 2006. 15.73 ©Silberschatz, Korth and Sudarshan
Two Phase Locking
Database System Concepts - 5th Edition, Sep 12, 2006. 15.74 ©Silberschatz, Korth and Sudarshan
Deadlock
Deadlock avoidance. The transaction must obtain all of the locks it needs
Database System Concepts - 5th Edition, Sep 12, 2006. 15.76 ©Silberschatz, Korth and Sudarshan
Handling Deadlocks
The choice of the best deadlock control method to use depends
listdeadlock avoidance .
Database System Concepts - 5th Edition, Sep 12, 2006. 15.77 ©Silberschatz, Korth and Sudarshan
Concurrency Control Techniques
Timestamping
A timestamp is a unique identifier for each transaction,
generated by the system.
Indicates the relative starting time of a transaction.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.78 ©Silberschatz, Korth and Sudarshan
Timestamping
Wait/Die
Wound/Wait Schemes
Database System Concepts - 5th Edition, Sep 12, 2006. 15.79 ©Silberschatz, Korth and Sudarshan
Database System Concepts - 5th Edition, Sep 12, 2006. 15.80 ©Silberschatz, Korth and Sudarshan
Time Stamping
Using the wait/die scheme:
Database System Concepts - 5th Edition, Sep 12, 2006. 15.81 ©Silberschatz, Korth and Sudarshan
Time Stamping
Using the wound/wait scheme:
causing a deadlock.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.83 ©Silberschatz, Korth and Sudarshan
Concurrency control with Optimistic
(Vaildation)Methods
The optimistic approach is based on the
assumption that the majority of the
database operations do not conflict.
The optimistic approach requires neither
locking nor time stamping techniques.
Instead, a transaction is executed without
restrictions until it is committed. Using an
optimistic approach, each transaction
moves through two or three phases,
referred to as read, validation, and write.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.84 ©Silberschatz, Korth and Sudarshan
Optimistic (Vaildation)Methods
During the read phase, the transaction reads the committed
data items from the database, executes the needed
computations, and makes the updates to a private copy of the
database values. All update operations of the transaction are
recorded in a temporary update file(transaction workspace),
which is not accessed by the remaining transactions.
During the validation phase, the transaction is validated to
ensure that the changes made will not affect the integrity and
consistency of the database. (to ensure that serializability will
not be violated)If the validation test is positive, the transaction
goes to the write phase. If the validation test is negative, the
transaction is restarted and the changes are discarded.
During the write phase, the changes are permanently applied
to the database.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.85 ©Silberschatz, Korth and Sudarshan
Optimistic (Vaildation)Methods
Database System Concepts - 5th Edition, Sep 12, 2006. 15.86 ©Silberschatz, Korth and Sudarshan
Database Recovery Management
Database System Concepts - 5th Edition, Sep 12, 2006. 15.87 ©Silberschatz, Korth and Sudarshan
Examples of Critical Events
Hardware/software failures. A failure of this type could be a hard disk media
failure, a bad capacitor on a motherboard, or a failing memory bank. Other
causes of errors under this category include application program or operating
system errors that cause data to be overwritten, deleted, or lost.
Human-caused incidents. This type of event can be categorized as
unintentional or intentional.
An unintentional failure is caused by carelessness by end users. Such
errors include deleting the wrong rows from a table, pressing the wrong
key on the keyboard, or shutting down the main database server by
accident.
Intentional events are of a more severe nature and normally indicate that
the company data are at serious risk. Under this category are security
threats caused by hackers trying to gain unauthorized access to data
resources and virus attacks caused by disgruntled employees trying to
compromise the database operation and damage the company.
Natural disasters. This category includes fires, earthquakes, floods, and
power failures.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.88 ©Silberschatz, Korth and Sudarshan
A transaction or system error: Some operations in the
transaction such as integer overflow or division by zero or
logical programming error may cause it to fail.
Local errors or exception conditions detected by the
transaction: certain conditions that may occur that
necessitate cancellation of transaction. (Notice that an
exception condition such as insufficient account balance
in a banking database may cause transaction such as
fund withdrawal to be canceled.)This exception should be
programmed in the transaction itself & hence would not
be considered a failure.
Concurrency Control Enforcement: the concurrency
control method may decide to abort the transaction, to be
restarted later, because it violates serializability or
because several transactions are in a state of deadlock.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.89 ©Silberschatz, Korth and Sudarshan
Transaction Recovery
Database transaction recovery uses data in the transaction log
Database System Concepts - 5th Edition, Sep 12, 2006. 15.90 ©Silberschatz, Korth and Sudarshan
2. Redundant transaction logs (several copies of the transaction
log) ensure that a physical disk failure will not impair the DBMS’s
ability to recover data.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.91 ©Silberschatz, Korth and Sudarshan
4. Database checkpoints are operations in which the
Database System Concepts - 5th Edition, Sep 12, 2006. 15.92 ©Silberschatz, Korth and Sudarshan
Recovery Technique
Database System Concepts - 5th Edition, Sep 12, 2006. 15.93 ©Silberschatz, Korth and Sudarshan
Recovery Techniques
DEFERRED UPDATE (deferred-write):
Database System Concepts - 5th Edition, Sep 12, 2006. 15.94 ©Silberschatz, Korth and Sudarshan
The Recovery Process For All Started And Committed
Transactions:
1. Identify the last checkpoint in the transaction log. (last time
transaction data was physically saved to disk.)
2. For a transaction that started and was committed before the
last checkpoint, nothing needs to be done because the data are
already saved.
3. For a transaction that performed a commit operation after the
last checkpoint, the DBMS uses the transaction log records to
redo the transaction and to update the database, using the
“after” values in the transaction log.The changes are made
in ascending order, from oldest to newest.
4. For any transaction that had a ROLLBACK operation after the
last checkpoint or that was left active (with neither a COMMIT
nor a ROLLBACK) before the failure occurred, nothing needs to
be done because the database was never updated.
Database System Concepts - 5th Edition, Sep 12, 2006. 15.95 ©Silberschatz, Korth and Sudarshan
Recovery Techniques
IMMEDIATE UPDATE (write through)
When a transaction issues an update command, the database
can be updated immediately, without any need to wait for the
transaction to reach its commit point.
If the recovery technique ensures that all updates of a
transaction are recorded in the database on disk before the
transaction commits, there is no need to redo any operations
of committed transactions.
Provision for undoing the effect of update operations that have
been applied to the database by a failed transaction.
It is possible that a transaction might have completed
execution and ready to commit but this transaction is also
undone. Such cases has to 15.96
undergo redo.
Database System Concepts - 5th Edition, Sep 12, 2006. ©Silberschatz, Korth and Sudarshan
The recovery process:
Identify the last checkpoint in the transaction log.
For a transaction that started and was committed before the last
checkpoint, nothing needs to be done because the data are
already saved.
For any transaction that had a ROLLBACK operation after the last
checkpoint or that was left active (with neither a COMMIT nor a
ROLLBACK) before the failure occurred, the DBMS uses the
transaction log records to ROLLBACK or undo the operations,
using the “before” values in the transaction log. Changes are
applied in reverse order, from newest to oldest.
For a transaction that was committed after the last checkpoint
Edited : Mrs.Pravicha.M.T
Database System Concepts, 5th Ed.
©Silberschatz, Korth and Sudarshan
See www.db-book.com for conditions on re-use