Information Technology Reference
In-Depth Information
an unrepeatable read. The locking protocol enforces the following execution order
for the actions of transactions T 1 and T 2 :
H 0 2 D T 1 W BR Œx
RŒyW Œ z C
T 2 W
BR Œy
W ŒyC
with locks granted as follows:
4. For WΠz , a commit-duration X lock on z for T 1 .
5. After C , the locks held by T 1 on x, y and z are released.
6. For WŒy, a commit-duration X lock on y for T 2 .
7. After C , the locks held by T 2 on y are released.
The history H 0 2
contains no isolation anomalies.
t
Rule (4) of the read-write locking protocol states that all locks acquired after
setting a savepoint P are released after a completed partial rollback to P .
Example 6.3 Consider the following transaction, which contains nested partial
rollbacks.
BR Œx 1 ; u 1 W Œx 1 ; u 1 ; v 1
SŒP 1 RŒx 2 ; u 2 W Œx 2 ; u 2 ; v 2
SŒP 2 W Œx 2 ; v 2 ; w 2 RŒx 3 ; u 3
AŒP 2 W 1 Œx 2 ; v 2 ; w 2 C ŒP 2 W Œx 2 ; v 2 ; w 0 2
AŒP 1 W 1 Œx 2 ; v 2 ; w 0 2 W 1 Œx 2 ; u 2 ; v 2 C ŒP 1 RŒx 2 ; u 2 W Œx 2 ; u 2 ; w 00 2 C .
Locks are acquired and released by the transaction as follows: (cf. Fig. 6.3 ):
1. For RŒx 1 ; u 1 ,anSlockonkeyx 1 .
2. For WŒx 1 ; u 1 ; v 1 ,anXlockonkeyx 1 .
3. For RŒx 2 ; u 2 ,anSlockonkeyx 2 .
4. For WŒx 2 ; u 2 ; v 2 ,anXlockonkeyx 2 .
5. For WŒx 2 ; v 2 ; w 2 ,nonewlock.
6. For RŒx 3 ; u 3 ,anSlockonkeyx 3 .
7. For W 1 Œx 2 ; v 2 ; w 2 ,nonewlock.
8. After CŒP 2 , the lock on x 3 is released.
9. For WŒx 2 ; v 2 ; w 0 2 ,nonewlock.
10. For W 1 Œx 2 ; v 2 ; w 0 2 ,nonewlock.
11. For W 1 Œx 2 ; u 2 ; v 2 ,nonewlock.
12. After CŒP 1 ,thelocksonx 2 are released.
13. For RŒx 2 ; u 2 ,anSlockonkeyx 2 .
14. For WŒx 2 ; u 2 ; w 00 2 ,anXlockonkeyx 2 .
15. After C ,thelocksonx 2 and x 1 are released.
First we note that each of the tuples with keys x 1 and x 2 written by the transaction is
kept X-locked until it is again in a committed state. Thus dirty writes are prevented.
Second, the transaction holds S locks on keys x 1 , x 2 ,andx 3 when reading the tuples
with those keys. Thus, dirty reads are prevented. Third, the S locks are kept until the
transaction commits or completes the partial rollback of an action sequence that
includes the read action for which the S lock was acquired.
Search WWH ::




Custom Search