Category 1 lost updates
When transaction a is canceled, the updated data of transaction B that has been committed is overwritten. This error may cause serious problems. You can see it through the following account withdrawal transfer:
Time |
Withdrawal transaction |
Transfer transaction B |
T1 |
Start transaction |
|
T2 |
|
Start transaction |
T3 |
The account balance is USD 1000. |
|
T4 |
|
The account balance is USD 1000. |
T5 |
|
Remit 100 yuan to change the balance to 1100 yuan |
T6 |
|
Commit transactions |
T7 |
Retrieve 100 yuan and change the balance to 900 yuan |
|
T8 |
Cancel transaction |
|
T9 |
The balance is restored to 1000 RMB (lost updates) |
|
When transaction a revokes the transaction, it accidentally erased the amount that transaction B has transferred to the Account.
Type 2 lost updates
Transaction A overwrites the data already submitted by transaction B, resulting in the loss of operations performed by transaction B:
Time |
Transfer transaction |
Withdrawal transaction B |
T1 |
|
Start transaction |
T2 |
Start transaction |
|
T3 |
|
The account balance is USD 1000. |
T4 |
The account balance is USD 1000. |
|
T5 |
|
Retrieve 100 yuan and change the balance to 900 yuan |
T6 |
|
Commit transactions |
T7 |
Import 100 RMB |
|
T8 |
Commit transactions |
|
T9 |
Change the balance to 1100 RMB (lost updates) |
|
In the above example, the check transfer transaction overwrites the withdrawal transaction's updates to the deposit balance, resulting in the Bank's final loss of 100 yuan. On the contrary, if the transfer transaction is committed first, the user account will lose 100 yuan.
Class 2 Dirty readThis means that when a transaction is accessing data and modifying the data has not been committed to the database, another transaction also accesses the data, then the data is used. Because the data has not been committed, the data read by another transaction is dirty data, and the operations performed based on the dirty data may be incorrect.
Update
When transaction a is canceled, the updated data of transaction B that has been committed is overwritten. This error may cause serious problems. You can see it through the following account withdrawal transfer:
Time |
Transaction |
Transaction B |
T1 |
Start transaction |
|
T2 |
|
Start transaction |
T3 |
Query the customer table |
|
T4 |
|
Query the customer table |
T5 |
|
The address field of the customer field has also been modified. |
T6 |
|
|
T7 |
Use the customer field of the table (false) |
|
T8 |
Commit transactions |
Commit transactions |
T9 |
The balance is restored to 1000 RMB (lost updates) |
|
Type 2 virtual read
It refers to a phenomenon that occurs when a transaction is not executed independently. For example, the first transaction modifies the data in a table, which involves all the data rows in the table. At the same time, the second transaction also modifies the data in this table. This modification inserts a new row of data into the table. In the future, the user who operates the first transaction will find that there are still data rows in the table that have not been modified, just like an illusion.
Category 3 unrepeatable read
A transaction reads the same data multiple times. When the transaction is not completed, another transaction also accesses the same data. Therefore, the data read twice in the first transaction may be different because of the modification of the second transaction. In this way, the data read twice in a transaction is different, so it is called non-repeated read.