Sunday, September 5, 2010

Db2 isolation level in bind

isolation level
An attribute that defines the degree to which an application process is isolated from other concurrently executing application processes.

uncommitted read (UR)
An isolation level that allows an application to access uncommitted changes of other transactions. The application does not lock other applications out of the row it is reading, unless the other application attempts to drop or alter the table.

cursor stability (CS)
An isolation level that locks any row accessed by a transaction of an application while the cursor is positioned on the row. The lock remains in effect until the next row is fetched or the transaction is terminated. If any data is changed in a row, the lock is held until the change is committed to the database.

read stability (RS)
An isolation level that locks only the rows that an application retrieves within a transaction. Read stability ensures that any qualifying row that is read during a transaction is not changed by other application processes until the transaction is completed, and that any row changed by another application process is not read until the change is committed by that process. Read stability allows more concurrency than repeatable read, and less than cursor stability.

repeatable read (RR)
An isolation level that locks all the rows in an application that are referenced within a transaction. When a program uses repeatable read protection, rows referenced by the program cannot be changed by other programs until the program ends the current transaction.


phantom row
A table row that can be read by application processes that are executing with any isolation level except repeatable read. When an application process issues the same query multiple times within a single unit of work, additional rows can appear between queries because of the data being inserted and committed by application processes that are running concurrently.

Can we better understand by the below table....



UR
CS
RS
RR
Can the application see uncommitted changes made by other application processes?
Yes
No
No
No
Can the application update uncommitted changes made by other application processes?
No
No
No
No
Can the re-execution of a statement be affected by other application processes? See phenomenon P3 (phantom) below.
Yes
Yes
Yes
No
Can "updated" rows be updated by other application processes?
No
No
No
No
Can "updated" rows be read by other application processes that are running at an isolation level other than UR?
No
No
No
No
Can "updated" rows be read by other application processes that are running at the UR isolation level?
Yes
Yes
Yes
Yes
Can "accessed" rows be updated by other application processes? See phenomenon P2 (nonrepeatable read) below.
Yes
Yes
No
No
Can "accessed" rows be read by other application processes?
Yes
Yes
Yes
Yes
Can "current" row be updated or deleted by other application processes? See phenomenon P1 (dirty-read) below
See Note below
See Note below
No
No

Examples of Phenomena:
P1
Dirty Read. Unit of work UW1 modifies a row. Unit of work UW2 reads that row before UW1 performs a COMMIT. If UW1 then performs a ROLLBACK, UW2 has read a nonexistent row.
P2
Nonrepeatable Read. Unit of work UW1 reads a row. Unit of work UW2 modifies that row and performs a COMMIT. If UW1 then re-reads the row, it might receive a modified value.
P3
Phantom. Unit of work UW1 reads the set of n rows that satisfies some search condition. Unit of work UW2 then INSERTs one or more rows that satisfies the search condition. If UW1 then repeats the initial read with the same search condition, it obtains the original rows plus the inserted rows.

No comments:

Post a Comment