Dirty Reads
A dirty read occurs when your application reads data from a database that has not been committed to permanent storage yet. Consider two instances of the same component performing the following:
- You read account balance X from the database. The database now contains X = 0.
- You add 10 to X and save it to the database. Now X = 10, but not committed, this is so-called dirty.
- Another instance reads X from database, it will get X = 10, which is dirty.
- You abort the transaction, which restores the X to 0.
- The other instance adds 10 to X and saves. The database now contains X = 20.
Unrepeatable Read
Unrepeatable read occur when a component reads data from database, but upon re-reading the same data, the data has been changed. This can arise when another concurrently executing transaction modifies the data. For example,
- You read a data set X from database.
- Another component overwrites all or part of the set X.
- You re-read the set X and values have changed.
Phantom
Phantom is a new set of data that inserted in a database between two read operations. For example:
- You read the database and find 5 computers ordered by A.
- A order another computer.
- You re-read the database and find 6 computers by A.
- If one of your transaction depends on the number of computers ordered, you will have problem to believe when the number will not change during your transaction.
No comments:
Post a Comment