Introduction to the first level, level two and level three blockade protocols

Source: Internet
Author: User

When using X and S locks to lock data objects, some rules need to be agreed, such as when to apply for an X lock or S lock, hold the lock time, and when to release. Called these rules for the blockade agreement (locking Protocol). The different rules governing the blockade form a variety of blockade agreements. Different blocking protocols provide certain guarantee for the correct dispatch of concurrent operation to different extent.

一、一级 Blockade Protocol

The first-level blockade protocol is that a transaction T must have an X lock on the data R before it is modified until the end of the transaction is released. The end of a transaction includes a normal end (COMMIT) and an abnormal end (ROLLBACK).

A lockdown protocol prevents loss of modification and guarantees that the transaction T is recoverable. Use of the first level of the blockade protocol can resolve the problem of loss modification.

In the first level blockade protocol, if only read data does not modify it, it does not need to be locked, it does not guarantee repeatable read and not read "dirty" data.

二、二级 Blockade Protocol

The second-order blockade protocol is: first-level blockade protocol plus transaction T before reading the data r must be added s lock, read the rear can release S lock.

The two-level blockade protocol, in addition to preventing the loss of changes, can further prevent the reading of "dirty" data. However, in the level two blockade protocol, the S lock can be released after reading the data, so it does not guarantee repeatable reading.

三、三级 Blockade Protocol

The level three blockade protocol is that a first-level blockade protocol plus transaction T must be added s lock to the data R before it is released until the end of the transaction.

The level three blockade protocol, in addition to preventing loss of modifications and not reading "dirty" data, further prevents the unreadable.

The main difference between these three-level agreements is what operations need to be blocked and when to release them.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Network/basis/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.