Home >Database >Mysql Tutorial >What problems may be caused by concurrent database operations?
# Concurrent operations of the database usually bring about lost update problems, inconsistent analysis problems and "dirty data" reading problems.
Introduction to relevant knowledge points:
Transaction is the basic unit of concurrency control.
(Related tutorial recommendations: mysql tutorial)
Data inconsistency caused by concurrent operations
1. Lost modifications (Lost Update)
2. Non-repeatable Read
3. Phantom Read
4. Read "dirty" data Read)
Let’s take a look at them separately:
Lost modifications: Two transactions T-1 and T-2 read the same data and modified it, and the submission result of T-2 destroyed T The result of -1 submission causes the modifications of T-1 to be lost. (Modification-Modification Conflict)
Non-repeatable read: Transaction 1 reads a certain data, and transaction 2 modifies it; when transaction 1 reads the data again, it gets a different value from the previous time (read -Update conflict)
Phantom reading: Transaction T-1 reads certain data records from the database according to certain conditions, and transaction T-2 deletes (inserts) some of the records. When T-1 presses again When reading data under the same conditions, it was found that some records mysteriously disappeared (appeared). (Read-insert/delete conflict)
Dirty data: Transaction T-1 modifies a certain data and writes it back to the disk; after transaction T-2 reads the same data, T-1 for some reason When T-1 is revoked, the modified data is restored to its original value, and the data read by T-2 is inconsistent with the data in the database. The data read by T-2 is "dirty" data, that is, incorrect data. (Modification - Read Conflict)
Data inconsistency: due to concurrent operations destroying the isolation of transactions
The purpose of concurrency control
must be used correctly This method schedules concurrent operations so that the execution of a user transaction is not interfered with by other transactions, thereby avoiding data inconsistency.
The above is the detailed content of What problems may be caused by concurrent database operations?. For more information, please follow other related articles on the PHP Chinese website!