table of Contents
Reasons for concurrency
There are multiple transactions that need to access the database. If they are in order, it will cause waste of resources (for example, transaction 1 does not require cpu, but transaction 2 requires cpu. At this time, wait for transaction 1 to complete before processing transaction 2, then In the process of processing transaction 1, the resource of cpu was wasted)
Concurrency control problems
Here, the abbreviation for transaction A is R(A), and the abbreviation for transaction A is W(A).
1. Lost data
2. Can not read repeatedly
3. Read dirty data
Solution
Locking protocol using
a total of three kinds of locking protocol
1. a locking protocol
2. The two locking protocol
3. The three locking protocol
specific in P313-314
Livelock and deadlock
Definition
Livelock: Slightly --> The solution is to adopt a first-request, first-to-do strategy (similar to a queue).
Deadlock: Slightly --> The solution is below, which is more complicated
(in book P315)
Deadlock solution
(1) One-time blocking
approach : require each transaction to lock all the data to be used at once.
Disadvantages : reduce concurrency
(2) sequential blocking
approach : prescribe a blocking sequence for data pairing (such as In the index of the B-tree structure, it is blocked from the root node level by level)
Disadvantages : difficult to maintain
It can be seen from the above that for deadlocks, the blocking method is not suitable for the database, and most databases use the diagnosis and removal of deadlocks
Diagnosis and removal of deadlock
(1) time-out law
practice : that if a transaction waiting time is a deadlock occurred
drawback : It may be false, if the set waiting time threshold is too large, there may not detect deadlocks
(2) wait for CLC
Method : drawing
The scope of the examination will not be involved in the future, I am not good at writing~