Information Technology Reference
In-Depth Information
Algorithm 6.4 Procedure set-savepoint .T; P /
n 0 U NDO -N EXT -LSN.T /
l L AST -L OCK .T /
log .n;hT; SŒP ; l 0 ;n 0 i/
U NDO -N EXT -LSN.T / n
Algorithm 6.5 Procedure complete-rollback-to-savepoint .T;P;l/
log .n;hT; CŒP i/
l 0 L AST -L OCK .T /
while l 0 6D nil and l 0 6D l do
release-lock .T; l 0 /
end while
6.3
Locking Protocol for the Read-Write Model
The programmer of a database application or a user that submits queries does not
need to worry about the locking of data items: the database management system
automatically invokes lock and unlock calls to acquire and release appropriate
locks for the database actions, issued by transactions. The system applies a locking
protocol that states which locks are acquired for which database actions, and when
each lock is requested and released. The locking protocol must ensure transactional
isolation, so that the transaction will run at the isolation levels set for it in all
histories that are permitted by the locking protocol.
In a locking protocol that guarantees a high degree of isolation, most of the
locks are commit-duration locks, that is, they are released only after the transaction
commits or completes a partial or total rollback. Usually the programmer of a
database application can affect the duration of locks only by setting appropriately
the transaction boundaries, using the SQL statements commit , rollback ,and
rollback to savepoint .
For the simple read-write transaction model, we define a locking protocol, called
read-write locking in this topic. Under this protocol, every transaction must follow
the following rules:
1. For a read action RŒx; v , a commit-duration S lock is acquired on the key x of
the tuple .x; v / to be read.
2. For a forward-rolling write action WŒx; u ; v , a commit-duration X lock is
acquired on the key x of the tuple that is to be written.
3. For an undo action W 1 Œx; u ; v , no lock is requested; the action is performed
under the protection of the commit-duration X lock acquired for the correspond-
ing forward-rolling action WŒx; u ; v .
 
Search WWH ::




Custom Search