TurboIMAGE/XL Database Management System Reference Manual MPE/iX V6.5 (30391-90011)
Chapter 7 315
Logging and Recovery
Logical Transactions
Figure 7-1. illustrates the concept of a logical transaction using a static and a dynamic
transaction. Note that a transaction block is also illustrated. A transaction block
consists of all transactions between a call to DBOPEN and a call to DBCLOSE. For further
information about transaction blocks, refer to "FILE Command" later in this chapter.
Figure 7-1. Transactions and Transaction Blocks
Locking Requirements for Logical Transactions
DBRECOV requires that all multiple-intrinsic database transactions execute independently
of all other transactions. Transaction independence within the database can be ensured in
a user program by locking data before a transaction and then releasing locks after a DBEND
or DBXEND is called, thus eliminating the possibility of another user modifying the same
data at the same time. The following example may clarify the need for locking data to be
modified.
Suppose transaction A consists of adding two records to the database that are later
modified by transaction B. Transaction B is dependent upon transaction A, because the
records must exist before they can be modified. Recall that a transaction is defined as a
sequence of one or more modifications that transfer the database from one consistent state
to another. A database may be in an inconsistent state during a transaction. Therefore, if
transactions A and B are executing concurrently without locking, transaction B may be
viewing the database in an inconsistent state and consequently could be generating
invalid results. However, if transaction A locks the data and completes properly, this
problem is avoided because transaction B cannot access the data until transaction A has
released its locks.
A second problem due to inadequate locking affects suppression of transactions by the
recovery system (see Figure 7-2.) Suppose transaction A intends to add six records to the
database, and after adding three records, transaction B is executed by another process.
Transaction B concurrently modifies one of the records added by transaction A and then
completes. Suppose that at this time, the system fails and recovery is executed. Because