Information Technology Reference
In-Depth Information
Here T 3 protects the read action RŒ3; > 1; v by acquiring a commit-duration S lock
on key 3, but this does not prevent T 4 from getting an X lock on key 2 for the insert
action IŒ2; v 2 . Thus, to prevent the unrepeatable read, we still have to obey the
standard key-range locking protocol and acquire a short-duration X lock on the next
key 3.
t
12.4
Statement-Level Read Consistency
Under statement-level read consistency , the read actions of every read-only trans-
action read from the start-time version, and the update actions of every update
transaction operate on the most recent tuple versions. Unlike with transaction-level
read consistency, the read actions by update transactions may be unrepeatable and
read from the most recent committed version as of the time when the SQL statement
that gave rise to the read action was started. Thus, all the tuples read by a single SQL
statement are read from the same committed version (except that, again, read actions
operating on tuples updated by the transaction itself read from the current version).
In a way, the start timestamp of an update transaction is advanced every time a new
SQL statement is invoked by the database application program that generates the
transaction.
Obviously, transactions run at statement-level read consistency, do neither dirty
writes nor dirty reads.
Example 12.6 Assume that the database contains initially the versioned tuples
.1; T 0 ; v 1 /, .2; T 0 ; v 2 /,and.3; T 0 ; v 3 /. In a single-version database, the history
T 1 :
BD Œ2; v 2
:::C
T 2 : BR Œx; > 1; v C
would exhibit a phantom dirty read, because then the read action RŒx; > 1; v is
RŒ3; >1; v 3 .
However, in a transaction-time database at statement-level read consistency the
read action is RŒ2; >1; v 2 . While searching the database for the tuple with the least
key x greater than 1, the read action RŒx; > 1; v encounters the tuples .2; T 0 ; v 2 /
and .2; T 1 ; ? /. As the version at time commit-time .T 0 / is the most recent committed
version, the read action must ignore .2; T 1 ; ? / and read the tuple .2; T 0 ; v 2 /. Thus
the history produced is equivalent to the serial history
T 1 :
BD Œ2; v 2 :::C
T 2 :
BR Œ2; > 1; v 2 C
t
Theorem 12.7 Statement-level read consistency prevents dirty writes and dirty
reads of all kinds and hence implies SQL isolation level 2 ı (read committed). t
The unrepeatable reads that may occur at statement-level read consistency
include lost updates, as defined in Sect. 9.5 .
Search WWH ::




Custom Search