Type of Lock:
There are two basic types of blocking: Exclusive lock (x Lock) and shared lock (S-lock). The so-called X-Lock, which is the transaction T to data a plus x lock, allows only transaction T to read and modify data a,... The so-called S-lock, is the transaction T to data a plus s lock, the other transaction can only add to the data a plus s lock, and cannot add x lock, until T release S lock on A. If the transaction T has an S lock on the data object A, T can read a, but not update (S lock is therefore called a read lock), before T releases the S lock on a, other transactions can be a plus s lock, but cannot add X lock, so that can read a, but not update a.
Level three lockdown protocol:
When using X-locks and S-Locks to lock data objects, there are rules that need to be agreed, such as when to apply for X-lock or S-lock, lock-in time, when to release, and so on. These rules are called the blockade Agreement (Locking Protocol). The different rules governing the way in which closures are imposed have created different kinds of blockade agreements.
一、一级 Blockade Protocol
The first-level blocking protocol is that transaction T must be X-locked before the data R is modified until the end of the transaction is released. The end of the transaction consists of a normal end (COMMIT) and an abnormal end (ROLLBACK).
The first-level blocking protocol prevents loss of modification and guarantees that the transaction T is recoverable. You can use the first-level blocking protocol to resolve lost modification issues.
In the first-level blocking protocol, if only the read data does not modify it, it does not need to be locked, it does not guarantee repeatable read and do not read "dirty" data.
二、二级 Blockade Protocol
Secondary blocking protocol is: the first level of the blockade protocol plus the transaction T before reading the data R must first add s lock, read the rear can release S lock.
The secondary blocking protocol, in addition to preventing loss of modification, can further prevent the reading of "dirty" data. However, in the level two blocking protocol, the S lock can be released after reading the data, so it cannot guarantee repeatable reads.
三、三级 Blockade Protocol
Level three blocking protocol is: the first level of the blockade protocol plus transaction T before reading the data r must be added to the S lock, until the end of the transaction is released.
The Level three lockdown protocol prevents non-repeatable reads, in addition to preventing loss of modification and non-reading of "dirty" data.
The main difference between the above level three protocol is what operations need to apply for blocking and when to release.
This connection is good for concurrency and lock introductions.
Http://course.cug.edu.cn/cug/database/database.htm