Unit 4 Part2 Transacmgt
Unit 4 Part2 Transacmgt
Introduction to Transaction
Processing Concepts and
Theory
Chapter 21 Outline
1 Introduction to Transaction Processing
2 Transaction and System Concepts
3 Desirable Properties of Transactions
4 Characterizing Schedules based on Recoverability
5 Characterizing Schedules based on Serializability
6 Transaction Support in SQL
Introduction to Transaction Processing
• Transaction: An executing program (process) that includes one or more
database access operations
– Read operations (database retrieval, such as SQL SELECT)
– Write operations (modify database, such as SQL INSERT, UPDATE,
DELETE)
– Transaction: A logical unit of database processing
– Example: Bank balance transfer of $100 dollars from a checking account
to a saving account in a BANK database
• Note: Each execution of a program is a distinct transaction with different
parameters
– Bank transfer program parameters: savings account number, checking
account number, transfer amount
Introduction to Transaction Processing (cont.)
• A transaction (set of operations) may be:
– stand-alone, specified in a high-level language like SQL
submitted interactively, or
– consist of database operations embedded within a program (most
transactions)
• Transaction boundaries: Begin and End transaction.
– Note: An application program may contain several transactions
separated by Begin and End transaction boundaries
Introduction to Transaction Processing (cont.)
• Transaction Processing Systems: Large multi-user
database systems supporting thousands of concurrent
transactions (user processes) per minute
• Two Modes of Concurrency
– Interleaved processing: concurrent execution of processes is
interleaved in a single CPU
– Parallel processing: processes are concurrently executed in
multiple CPUs (Figure 21.1)
– Basic transaction processing theory assumes interleaved
concurrency
Introduction to Transaction Processing (cont.)
For transaction processing purposes, a simple database model
is used:
• A database - collection of named data items
• Granularity (size) of a data item - a field (data item value), a
record, or a whole disk block
– TP concepts are independent of granularity
• Basic operations on an item X:
– read_item(X): Reads a database item named X into a
program variable. To simplify our notation, we assume that
the program variable is also named X.
– write_item(X): Writes the value of program variable X into
the database item named X.
Introduction to Transaction Processing (cont.)
•
• 3. Local errors or exception conditions detected by
the transaction:
• - certain conditions necessitate cancellation of the
transaction. For example, data for the transaction may
not be found. A condition, such as insufficient account
balance in a banking database, may cause a
transaction, such as a fund withdrawal, to be canceled
- a programmed abort causes the transaction to fail.
• 4. 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 (see Chapter 22).
Why recovery is needed (cont.)
•
• 5. Disk failure: Some disk blocks may lose their
data because of a read or write malfunction or
because of a disk read/write head crash. This kind of
failure and item 6 are more severe than items 1
through 4.
• 6. Physical problems and catastrophes: This refers
to an endless list of problems that includes power or
air-conditioning failure, fire, theft, sabotage,
overwriting disks or tapes by mistake, and mounting
of a wrong tape by the operator.
Transaction and System Concepts
• Schedule A: r1(X); w1(X); r2(X); w2(X); c2; r1(Y); w1(Y); c1 (or a1)
• Schedule B: r1(X); w1(X); r2(X); w2(X); r1(Y); w1(Y); c1 (or a1); ...
Characterizing Schedules based on
Recoverability (cont.)
Recoverable schedules can be further refined:
• Cascadeless schedule: A schedule in which a transaction
T2 cannot read an item X until the transaction T1 that last
wrote X has committed.
• The set of cascadeless schedules is a subset of the set of
recoverable schedules.
In Sa, the operations w2(X) and w3(X) are blind writes, since T2
and T3 do not read the value of X.