When concurrent transactions are processed, inconsistent situations can occur. Try and avoid these situations by setting the lock behavior and isolation level of the database system accordingly. The following phenomena can occur if the same data is accessed concurrently:
· Dirty Read
A row is modified by transaction T1, and transaction T2 reads this row before T1 has been completed with the COMMIT statement. T1 then executes the ROLLBACK statement. In this case, T2 has read a row that never existed.
· Non-Repeatable Read
Transaction T1 reads a row. Transaction T2 then modifies or deletes this row, and completes the action with the commit statement. If T1 then reads the row again, it either gets the modified row or a message indicating that the row no longer exists.
· Phantom
Transaction T1 executes an SQL statement S that reads a set of rows (M) that fulfill a search condition. Transaction T2 then inserts or modifies data, and produces another row that fulfills this search condition. If T1 then executes the statement S again, the set of rows that is read differs from the set M.
This table gives you an overview of which phenomena occur in which isolation level.
|
Isolation Level 0 |
Isolation Level 1 or 10 |
Isolation Level 2 or 20 |
Isolation Level 3 or 30 |
Dirty Read |
+ |
- |
- |
- |
Non-Repeatable Read |
+ |
+ |
- |
- |
Phantom |
+ |
+ |
+ |
- |