Write-read conflict
A write-read conflict (also English dirty read ) occurs in the computer science when two concurrent transactions a transaction reads data written by the other transaction or modified but not yet confirmed ( committed ) are.
example
The following transaction could occur when users log on to a wiki:
-
Transaktionsanfang
Transaktionsende
At the same time, a function with which a user can display a list of logged-in users could perform the following transaction:
-
Transaktionsanfang
- Select all user records (action 2a)
- Output the user data found as a colorful website
Transaktionsende
Without transaction isolation , a read / write conflict can occur in the following way , which leads to a data record that actually does not yet exist being output:
time | Transaction 1 | Transaction 2 | effect |
---|---|---|---|
1 | Action 1a | User data record is temporarily created | |
2 | Action 1b | Block list is read; user is locked | |
3 | Action 2a | The preliminary user data record is also output | |
4th | Rollback | The temporarily created data record is removed again |
remedy
Databases usually offer the option of transaction isolation . With isolation through serialization , the above sequence could look like this, for example; the read-write conflict is avoided:
time | Transaction 1 | Transaction 2 | effect |
---|---|---|---|
1 | Action 1a | User data record is temporarily created | |
2 | Action 1b | Block list is read; user is locked | |
3 | Action 2a | Table locked: transaction must wait | |
4th | Rollback | The temporarily created data record is removed again | |
5 | Action 2a | Transaction is continued, provisional entry is not included |