What Is Concurrency Control?
In computer science, especially in the areas of programming, operating systems, multiprocessing, and databases, concurrency control is a mechanism that ensures that errors caused by concurrent operations are corrected in a timely manner. The basic unit of concurrency control is a transaction.
- In computer science, especially in the areas of programming, operating systems, multiprocessing, and databases, concurrency control is a mechanism that ensures that errors caused by concurrent operations are corrected in a timely manner. The basic unit of concurrency control is a transaction.
Concurrency control mechanism
- Concurrency control refers to various technologies used to protect the integrity of the database when multiple users update the runtime at the same time. Incorrect concurrency mechanisms can cause such problems as dirty reads, phantom reads, and non-repeatable reads. The purpose of concurrency control is to ensure that the work of one user does not unreasonably affect the work of another user. In some cases, these measures ensure that when a user operates with other users, the results obtained are the same as when she operates alone. In other cases, this means that the user's work is influenced by other users in a predetermined way.
Concurrency control applications
- Concurrency control in database management systems
- The task of concurrency control in a database management system (DBMS) is to ensure that when multiple transactions access the same data in the database at the same time, the isolation and unity of the transaction and the unity of the database are not destroyed. The following example illustrates the data inconsistency caused by concurrent operations:
- There are two train ticket sales points at the same time, and the ticket balance in a certain train ticket database is read as X. Two ticketing outlets sold one ticket at the same time, and the balance was changed to X -1 and written back to the database. This resulted in the actual sale of two train tickets and only one less record in the database.
- The reason for this is that two transactions read the same data and modify them at the same time. The result of one transaction's commit destroys the result of the other transaction's commit, causing its data modification to be lost and the transaction's isolation. This type of problem is what concurrency control is about to solve.
- Blocking, time stamping, optimistic concurrency control, pessimistic concurrency control, multi-version and snapshot isolation are the main technical methods used for concurrency control.