Home  >  Article  >  Database  >  What problems may arise from concurrent database operations?

What problems may arise from concurrent database operations?

angryTom
angryTomOriginal
2019-07-24 15:17:0110708browse

What problems may arise from concurrent database operations?

Recommended tutorial: sql tutorial

What is a database Concurrent operations

# The database is a shared resource that can be used by multiple users. These user programs can be executed serially one by one. Only one user program is running at a time to access the database. Other user programs must wait until this user program ends before they can access the database. But if a user program involves the input/output exchange of large amounts of data, the database system will be idle most of the time. Therefore, in order to make full use of database resources and take advantage of the characteristics of database shared resources, multiple users should be allowed to access the database in parallel. However, this will cause multiple user programs to concurrently access the same data. If concurrent operations are not controlled, incorrect data may be accessed and stored, destroying the consistency of the database. Therefore, the database management system must provide concurrency control. mechanism. The quality of the concurrency control mechanism is one of the important indicators of measuring the performance of a database management system.

Problems caused by concurrent database operations

(1) Lost updates

When two When one or more things read and modify the same data, a lost update problem will occur, that is, the result of the update of the later transaction is overwritten by the update of the previous transaction. That is, when transactions A and B are concurrently performed, transaction A has changed the data but B modified the same data before submitting it (note that the data at this time is the data that A has not yet submitted the change), and the data changes made by A will be lost

(2) Non-repeatable Read

When two data reads a certain data, another transaction performs an update to the data, and the current transaction reads the data again (hopefully the same as the first read) (the same value), the data obtained is different from the previous one. This is because after the data was read for the first time, transaction B modified it, causing the data to be read again to be different from the data read for the first time. Same as

(3) Reading 'dirty data'

When a transaction modifies a certain data, another transaction reads the data. Due to some kind of The reason is that the previous transaction canceled the modification of the modified data and restored the modified data to its original value. Then the data read by the latter transaction is inconsistent with the available data, which is called reading dirty data

Note: Also There is something called "Ghost Data" Ghost data is similar to dirty data, but ghost data refers to the data read after the transaction is committed, but after reading, the previous transaction is restored, and dirty data Data refers to data read before submission

The above is the detailed content of What problems may arise from concurrent database operations?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn