MODULE
MODULE
CHAPTER-11
TRANSACTION PROCESSING
Transaction processing:
The concept of transaction provides a mechanism for describing logical
units of database processing.
Transaction processing systems are systems with large databases and
hundreds of concurrent users executing database transactions.
Examples of such systems include airline reservations, banking, credit
card processing, online retail purchasing, stock markets, supermarket
checkouts, and many other applications.
These systems require high availability and fast response time for
hundreds of concurrent users.
1. Single user
2. Multiuser.
Single - User:
o At most one user at a time can use the system.
o Single-user DBMSs are mostly restricted to personal computer
systems.
Multi-User:
o Many users can use the system and hence access the database
concurrently.
o Database systems used in banks, insurance agencies, stock exchanges,
supermarkets, airline agencies and many other applications are multiuser
systems.
o Multiple users can access databases and use computer system
simultaneously because of the concept of multiprogramming (to execute
multiple programs or processes at the same time).
o In a multiuser DBMS, the stored data items are the primary resources that
may be accessed concurrently by users or programs, which are constantly
retrieving information from and modifying the database.
Database items:
A database is basically represented as a collection of named data items.
The size of a data item is called its granularity.
A data item can be a database record, but it can also be a larger unit
such as a whole disk block, or even a smaller unit such as an individual
field (attribute) value of some record in the database.
Each data item has a unique name, used to uniquely identify each data
item.
For example, if the data item granularity is one disk block, then the disk
block address can be used as the data item name. If the item
granularity is a single record, then the record ID can be the item name.
Read and write operations:
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.
For example,
If X = 80 at the start (originally there were 80 reservations on the flight), N = 5 (T1 transfers 5 seat
reservations from the flight corresponding to X to the flight corresponding to Y), and M = 4 (T2 reserves
4 seats on X), the final result should be X = 79. However, in the interleaving of operations shown in
Figure (a), it is X = 84 because the update in T1 that removed the five seats from X was lost
For example,
suppose that a transaction T3 is calculating the total number of reservations on all the flights;
meanwhile, transaction T1 is executing. If the interleaving of operations shown in Figure 20.3(c) occurs,
the result of T3 will be off by an amount N because T3 reads the value of X after N seats have been
subtracted from it but reads the value of Y before those N seats have been added to it.
4.The Unrepeatable Read Problem:
Another problem that may occur is called unrepeatable read, where a
transaction T reads the same item twice and the item is
changed by another transaction T′ between the two reads. Hence, T
receives different values for its two reads of the same item. This may
occur, for example, if during an airline reservation transaction, a
customer inquires about seat availability on several flights. When the
customer decides on a particular flight, the transaction then reads the
number of seats on that flight a second time before completing the
reservation, and it may end up reading a different value for the item.
Why Recovery Is Needed:-
Types of Failures:-
Failures are generally classified as transaction, system, and media failures. There
are several possible reasons for a transaction to fail in the middle of execution:
Whenever a failure of type 1 through 4 occurs, the system must keep sufficient
information to quickly recover from the failure. Disk failure or other catastrophic
failures of type 5 or 6 do not happen frequently; if they do occur, recovery is a
major task.