Professional Documents
Culture Documents
Database System Concepts 15.1 ©Silberschatz, Korth and Sudarshan Database System Concepts 15.2 ©Silberschatz, Korth and Sudarshan
Database System Concepts 15.3 ©Silberschatz, Korth and Sudarshan Database System Concepts 15.4 ©Silberschatz, Korth and Sudarshan
! Durability requirement — once the user has been notified ! Active, the initial state; the transaction stays in this state
that the transaction has completed (i.e., the transfer of the while it is executing
$50 has taken place), the updates to the database by the ! Partially committed, after the final statement has been
transaction must persist despite failures. executed.
! Isolation requirement — if between steps 3 and 6, another ! Failed, after the discovery that normal execution can no
longer proceed.
transaction is allowed to access the partially updated
database, it will see an inconsistent database ! Aborted, after the transaction has been rolled back and the
(the sum A + B will be less than it should be). database restored to its state prior to the start of the
transaction. Two options after it has been aborted:
Can be ensured trivially by running transactions serially,
that is one after the other. However, executing multiple ! restart the transaction – only if no internal logical error
transactions concurrently has significant benefits, as we ! kill the transaction
will see. ! Committed, after successful completion.
Database System Concepts 15.5 ©Silberschatz, Korth and Sudarshan Database System Concepts 15.6 ©Silberschatz, Korth and Sudarshan
Database System Concepts 15.7 ©Silberschatz, Korth and Sudarshan Database System Concepts 15.8 ©Silberschatz, Korth and Sudarshan
Implementation of Atomicity and Durability
Concurrent Executions
(Cont.)
The shadow-database scheme:
! Multiple transactions are allowed to run concurrently in the
system. Advantages are:
! increased processor and disk utilization, leading to better
transaction throughput: one transaction can be using the CPU
while another is reading from or writing to the disk
! reduced average response time for transactions: short
transactions need not wait behind long ones.
! Concurrency control schemes – mechanisms to achieve
isolation, i.e., to control the interaction among the
concurrent transactions in order to prevent them from
destroying the consistency of the database
! Will study in Chapter 14, after studying notion of correctness of
concurrent executions.
! Assumes disks to not fail
! Useful for text editors, but extremely inefficient for large
databases: executing a single transaction requires copying
the entire database. Will see better schemes in Chapter 17.
Database System Concepts 15.9 ©Silberschatz, Korth and Sudarshan Database System Concepts 15.10 ©Silberschatz, Korth and Sudarshan
Database System Concepts 15.11 ©Silberschatz, Korth and Sudarshan Database System Concepts 15.12 ©Silberschatz, Korth and Sudarshan
Database System Concepts 15.15 ©Silberschatz, Korth and Sudarshan Database System Concepts 15.16 ©Silberschatz, Korth and Sudarshan
Conflict Serializability (Cont.) Conflict Serializability (Cont.)
! If a schedule S can be transformed into a schedule S´ by a
series of swaps of non-conflicting instructions, we say that ! Schedule 3 below can be transformed into Schedule 1, a
S and S´ are conflict equivalent. serial schedule where T2 follows T1, by series of swaps of
! We say that a schedule S is conflict serializable if it is non-conflicting instructions. Therefore Schedule 3 is conflict
conflict equivalent to a serial schedule serializable.
Database System Concepts 15.17 ©Silberschatz, Korth and Sudarshan Database System Concepts 15.18 ©Silberschatz, Korth and Sudarshan
Database System Concepts 15.19 ©Silberschatz, Korth and Sudarshan Database System Concepts 15.20 ©Silberschatz, Korth and Sudarshan
Database System Concepts 15.21 ©Silberschatz, Korth and Sudarshan Database System Concepts 15.22 ©Silberschatz, Korth and Sudarshan
Database System Concepts 15.23 ©Silberschatz, Korth and Sudarshan Database System Concepts 15.24 ©Silberschatz, Korth and Sudarshan
Implementation of Isolation Transaction Definition in SQL
! Data manipulation language must include a construct for
! Schedules must be conflict or view serializable, and
specifying the set of actions that comprise a transaction.
recoverable, for the sake of database consistency, and
preferably cascadeless. ! In SQL, a transaction begins implicitly.
! A transaction in SQL ends by:
! A policy in which only one transaction can execute at a time
generates serial schedules, but provides a poor degree of ! Commit work commits current transaction and begins a new
one.
concurrency..
! Rollback work causes current transaction to abort.
! Concurrency-control schemes tradeoff between the amount
! Levels of consistency specified by SQL-92:
of concurrency they allow and the amount of overhead that
they incur. ! Serializable — default
! Repeatable read
! Some schemes allow only conflict-serializable schedules to
be generated, while others allow view-serializable ! Read committed
schedules that are not conflict-serializable. ! Read uncommitted
Database System Concepts 15.25 ©Silberschatz, Korth and Sudarshan Database System Concepts 15.26 ©Silberschatz, Korth and Sudarshan
y
Database System Concepts 15.27 ©Silberschatz, Korth and Sudarshan Database System Concepts 15.28 ©Silberschatz, Korth and Sudarshan
Database System Concepts 15.31 ©Silberschatz, Korth and Sudarshan Database System Concepts 15.32 ©Silberschatz, Korth and Sudarshan
Concurrency Control vs. Serializability Tests
Database System Concepts 15.35 ©Silberschatz, Korth and Sudarshan Database System Concepts 15.36 ©Silberschatz, Korth and Sudarshan
Database System Concepts 15.37 ©Silberschatz, Korth and Sudarshan Database System Concepts 15.38 ©Silberschatz, Korth and Sudarshan
Database System Concepts 15.39 ©Silberschatz, Korth and Sudarshan Database System Concepts 15.40 ©Silberschatz, Korth and Sudarshan
Precedence Graph fig. 15.21
Database System Concepts 15.41 ©Silberschatz, Korth and Sudarshan Database System Concepts 15.42 ©Silberschatz, Korth and Sudarshan