Home >Daily Programming >Mysql Knowledge >What are the units of concurrency control?

What are the units of concurrency control?

烟雨青岚
烟雨青岚Original
2020-07-08 14:28:3912706browse

The basic unit of concurrency control is a transaction. Concurrency control refers to various technologies used to protect the integrity of the database when multiple users update and run at the same time; incorrect concurrency mechanisms may lead to problems such as dirty reads, phantom reads, and non-repeatable reads.

What are the units of concurrency control?

#The basic unit of concurrency control is a transaction.

In computer science, especially in the fields of programming, operating systems, multiprocessing, and databases, concurrency control is a mechanism to ensure that errors caused by concurrent operations are corrected in a timely manner.

Concurrency control refers to various technologies used to protect the integrity of the database when multiple users update and run at the same time.

Incorrect concurrency mechanism may lead to problems such as dirty reads, phantom reads, and non-repeatable reads.

The purpose of concurrency control is to ensure that the work of one user will not have an unreasonable impact on the work of another user.

In some cases, these measures ensure that when a user operates together with other users, the results obtained are the same as when she operates alone. In other cases, it means that a user's work is affected by other users in a predetermined way.

Concurrency control in database management systems

The task of concurrency control in database management systems (DBMS) is to ensure that multiple transactions access the database at the same time The isolation and unity of transactions and the unity of the database will not be destroyed when the same data is stored. The following example illustrates the data inconsistency problem caused by concurrent operations:

There are two train ticket sales points, and the ticket balance in a certain train ticket database is read at the same time as X. Two ticket sales points sold a ticket at the same time, and at the same time modified the balance to X -1 and wrote it back to the database. This resulted in two train tickets being actually sold but only one missing in the record in the database.

The reason for this situation is that two transactions read the same data and modify it at the same time. The result submitted by one transaction destroys the result submitted by the other transaction, causing the modification of its data to be lost and destroyed. Transaction isolation. Concurrency control is intended to solve this type of problem.

Blocking, timestamps, optimistic concurrency control, pessimistic concurrency control, multi-version and snapshot isolation are the main technical means used for concurrency control.

Recommended tutorial: "MySQL Tutorial"

The above is the detailed content of What are the units of concurrency control?. 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