Professional Documents
Culture Documents
• Durability – ensures that once transaction A DBMS uses a transaction log to keep track of all
changes are done (committed), they cannot be transactions that update the database. The
undone or lost, even in the vent of system information may be used by the DBMS for a recovery
failure. requirement by rollback statements, an abnormal
termination, or system failure.
• Serializability – ensures that the concurrent
execution of several transactions yield
consistent results. That is, the concurrent Concurrency Control
execution of transactions T1, T2, and T3 yields
results that appear to have been executed in The coordination of the simultaneous execution of
serial order. transactions in a multiuser database system is known
as concurrency control. Its main objective is to
ensure the Serializability of transactions in a multiuser
database environment.
Transaction Management with SQL
Concurrency control aims to resolve:
ANSI has defined standards to govern over SQL
database transactions. Transaction support is provided 1. Lost Updates
by: COMMIT and ROLLBACK. ANSI requires that when Without concurrency control, updates may be
a transaction sequence is initiated by the user or an lost.
application program, the sequence must continue Consider the following transactions:
through all succeeding statements until one of the T1 : purchase 100 units
following occurs: T2 : sell 30 units
Both transactions refer to the same
1. A COMMIT statement is reached. Changes are
product. The product currently has 35
permanently recorded within the database.
units.
2. A ROLLBACK statement is reached. All changes
T1 and T2 read that value they each get
are aborted and the database is returned to the
35.
previous consistent state.
Then T1 adds 100 units to that quantity
3. The end of the program is successfully reached.
making it 135 (35 + 100) but T2 subtracts
This should be equivalent to a COMMIT.
30 units making it 5 (35-30).
T1 then writes the updated value to the has deducted the value of 10 from A but
database (quantity is 135). not yet added 10 to AA. The counts would
T2 also writes the updated value to the be off by 10.
database (quantity is 5).
Because T2 writes after T1, T1’s update is lost,
the only transaction actually saved will be T2. Scheduler
The time stamping approach to scheduling When using time stamps to manage concurrent
concurrent transactions assigns a global, unique transactions, there are two schemes that can be
timestamp to each transaction. The time stamp value applied to decide which transaction is rolled back and
produces an explicit order in which transactions are which continues executing:
submitted to the DBMS.
Assume: T1 has time stamp of 11548789 and T2 has
time stamp of 19562545
Time stamps must have two properties:
Transacti Transacti
Wait/Die Wound/Wait
1. Uniqueness. This ensures that no equal time on on
Scheme Scheme
Requesti Owning
stamp value can exist.
ng Lock Lock
T1 T2 • T1 waits until • T1 preempts
T2 is
(rolls back) T2 • A differential backup of the database, in
• T2 is which only the last modifications to the
completed and
rescheduled database (compared to a previous backup copy)
T2 releases its
using the same are copied
locks
time stamp
• T2 dies (rolls • A transaction log backup, which backs up
back) • T2 waits until only the transaction log operations that are not
• T2 is T1 is reflected in a previous backup copy of the
T2 T1
rescheduled completed and
database.
using the T1 releases its
same time locks
The database backup is stored in a secure place,
stamp
usually in a different building, and is protected against
dangers such as fire, theft, flood, and other potential
In both schemes, transactions may wait for lock calamities. The backup’s existence guarantees
requests and that may cause deadlocks, to prevent database recovery following system
this, each lock request has an associated time-out (hardware/software) failures.
value. If the lock is not granted before the time-out
Causes / Factors of system failures:
expires, the transaction is rolled back.
• Software
• Transactions
o The system detects deadlocks and aborts
one of the transactions.
Transaction Recovery
• External Factors
The database recovery process involves bringing the
o Fire, earthquake, flood, or other natural database to a consistent state after a failure.
disasters Transaction recovery procedures generally make use
of deferred-write and write-through techniques.
Concepts that affect the recovery process:
When the recovery procedure uses deferred-write or
• The write-ahead-log-protocol. This ensures deferred-update, the transaction operations do not
that transaction logs are always written before immediately update the physical database. Instead,
any database data are actually updated so that, only the transaction log is updated. The database is
in case of failure, the database can later be physically updated only after transaction reaches its
recovered to a consistent state using the data in commit point, using the transaction log information. If
the transaction log. the transaction aborts before it reaches to its commit
point, no changes (no ROLLBACK or undo) need to be
• Redundant transaction logs. Several copies made to the database because the database was
of the transaction log ensure that a copy is never updated. The recovery process for all started
available even when there is physical disk and committed transaction (before the failure) will
failure. follow the steps: