TMF Introduction (G06.26+)
TMF Application Programming
HP NonStop TMF Introduction—522414-002
5-3
Controlling Transaction Isolation
Controlling Transaction Isolation
Applications can achieve different levels of isolation from concurrent programs by
using various locking techniques for transactions. With the lowest level of isolation, a
transaction accesses data for read operations only, despite any locks by concurrent
transactions. With the highest level of isolation, a transaction acquires locks on data for
its exclusive use only, prohibiting any access to the data by other transactions.
As transaction isolation increases, concurrency decreases: application designers,
therefore, need to balance application requirements for concurrency against
requirements for isolation.
Most databases, including NonStop SQL and Enscribe databases, allow for various
levels of isolation; NonStop SQL access, however, provides greater concurrency with a
higher level of isolation than does Enscribe access.
The following discussion describes levels of isolation—from the lowest to the highest—
as choices in locking techniques:
•
Disregarding locks on data (reading uncommitted data)
•
Locking for Read and Update
•
Locking for repeatable access
Disregarding Locks on Data (Reading Uncommitted Data)
This isolation level applies only to reading data and allows a transaction to read data
even if it is locked by another transaction. This allows the transaction to gather
information without waiting for other transactions to complete. However, the
transaction may read data that is in transition or inaccurate, because of uncommitted
transactions. For example, an application could retrieve data about a sale in progress
that is subsequently backed out (aborted). Transactions that disregard locks have no
isolation from other transactions; therefore, they have the highest level of concurrency.
Embedded SQL applications disregard locks for data by specifying READ
UNCOMMITTED. Applications using Enscribe databases disregard locks for data by
specifying a read with no lock.
Locking Data for Read and Update
When locking for read and update, an application acquires locks on the
accessed data. The locks protect the application from accessing data affected
by uncommitted updates of other transactions.
Typically, the data that an application reads has a shared lock, but the data that the
application updates has an exclusive lock. A shared lock allows any number of
Note. This discussion on locking is general: the different programming languages each
provide their own options for more varied control. These are discussed in the individual
programming language manuals.