2019329621077唐晓莲homework-5 Version 0 |
|
👤 Author: by 1097682897qqcom 2021-11-09 20:41:07 |
There are two scenic spot ticket sales points, and the remaining number of people who can make an appointment on the same day is X. Two ticket outlets sell one ticket at the same time, and the modified quantity is X - 1, which is written back to the database. In this way, two tickets are actually sold, but only one ticket is missing in the database. The reason for this is that two transactions read the same data and modify it at the same time. The result of one transaction's submission destroys the result of the other transaction's submission, resulting in the loss of its data modification and the isolation of transactions.
The solution is to lock the data when one of them modifies the data, so that others cannot change the data. When they want to change, they return an exception.