文档章节

Intention Locks && Intention Locking Protocol

秋风醉了
 秋风醉了
发布于 2015/11/14 17:13
字数 487
阅读 246
收藏 0

Intention Locks && Intention Locking Protocol

http://dev.mysql.com/doc/refman/5.6/en/glossary.html#glos_intention_lock

Intention Locks

A kind of lock that applies to the table level, used to indicate what kind of lock the transaction intends to acquire on rows in the table. Different transactions can acquire different kinds of intention locks on the same table, but the first transaction to acquire an intention exclusive (IX) lock on a table prevents other transactions from acquiring any S or X locks on the table. Conversely(相反的), the first transaction to acquire an intention shared (IS) lock on a table prevents other transactions from acquiring any X locks on the table. The two-phase process allows the lock requests to be resolved in order, without blocking locks and corresponding operations that are compatible.

Additionally,InnoDB supports multiple granularity(间隔尺寸,粒度) locking which permits coexistence(共存,并立) of record locks and locks on entire tables. To make locking at multiple granularity levels practical, additional types of locks called intention locks are used. Intention locks are table locks in InnoDB that indicate which type of lock (shared or exclusive) a transaction will require later for a row in that table. There are two types of intention locks used in InnoDB (assume that transaction T has requested a lock of the indicated type on table t):

Intention shared (IS): Transaction T intends to set S locks on individual rows in table t.

Intention exclusive (IX): Transaction T intends to set X locks on those rows.

For example, SELECT ... LOCK IN SHARE MODE sets an IS lock and SELECT ... FOR UPDATE sets an IX lock.

 

Intention Locking Protocol

The intention locking protocol is as follows:

Before a transaction can acquire an S lock on a row in table t, it must first acquire an IS or stronger lock on t.

Before a transaction can acquire an X lock on a row, it must first acquire an IX lock on t.

These rules can be conveniently summarized by means of the following lock type compatibility matrix(相容性矩阵).

  X IX S IS
X Conflict Conflict Conflict Conflict
IX Conflict Compatible Conflict Compatible
S Conflict Conflict Compatible Compatible
IS Conflict Compatible Compatible Compatible

A lock is granted to a requesting transaction if it is compatible(兼容的,相容的) with existing locks, but not if it conflicts with existing locks. A transaction waits until the conflicting existing lock is released. If a lock request conflicts with an existing lock and cannot be granted because it would cause deadlock, an error occurs.

 

Thus, intention locks do not block anything except full table requests (for example, LOCK TABLES ... WRITE). The main purpose of IX and IS locks is to show that someone is locking a row, or going to lock a row in the table.

==============END==============

© 著作权归作者所有

下一篇: MySQL锁的调试
秋风醉了
粉丝 253
博文 532
码字总数 405755
作品 0
朝阳
程序员
私信 提问
加载中

评论(0)

InnoDB Lock Modes

InnoDB Lock Modes http://dev.mysql.com/doc/refman/5.7/en/innodb-lock-modes.html InnoDB implements standard row-level locking where there are two types of locks, shared (S) locks......

秋风醉了
2015/11/13
53
0
【 58沈剑 架构师之路】InnoDB七种锁——共享/排它锁、意向锁、插入意向锁

今天,将要介绍InnoDB另外三种:共享/排他锁,意向锁,插入意向锁。 一,共享/排它锁(Shared and Exclusive Locks) 《InnoDB并发为何这么高?》一文介绍了通用的共享/排它锁,在InnoDB里当然...

张锦飞
2018/12/07
414
0
InnoDB Record, Gap, and Next-Key Locks

InnoDB Record, Gap, and Next-Key Locks http://dev.mysql.com/doc/refman/5.7/en/innodb-record-level-locks.html InnoDB has several types of record-level locks including record lock......

秋风醉了
2015/11/13
103
0
InnoDB中的锁

InnoDB 中的锁 本文翻译自mysql5.6官方文档:InnoDB Locking 本文介绍InnoDB包含的锁的种类: 共享锁(Shared Lock)和 排他锁(Exclusive Lock) 意向锁(Intention Locks) Record Locks Gap Lo...

Gen_zhou
2016/07/21
202
0
MySQL InnoDB Lock Modes

行锁的S锁和X锁 Innodb实施标准的行级锁,其中有两种类型的锁: Shared lock即共享锁,S锁。如果事务对数据行r持有S锁,那么允许其它事务对数据行r持有S锁,但不允许其它事务对数据行持有X锁...

未央&
2019/03/31
0
0

没有更多内容

加载失败,请刷新页面

加载更多

深圳哪里可以开家用电器发票-中国-新闻网

深圳哪里可以开家用电器发票【152 * 9б 28 * 21 б9】陈生,诚、信、合、作,保、真、售、后、保、障、长、期、有、效。adb的全称为Android Debug Bri...

17060824738
16分钟前
41
0
深圳哪里可以开劳保用品发票-中国-新闻网

深圳哪里可以开劳保用品发票【152 * 9б 28 * 21 б9】陈生,诚、信、合、作,保、真、售、后、保、障、长、期、有、效。adb的全称为Android Debug Bri...

17095420210
19分钟前
36
0
Mac OS X 10.15 编译和安装 Nginx

想在自己电脑里装个 Nginx 来进行各种测试,下面是详细的过程记录: 1. 下载软件 首先建个临时目录 nginx-src 并下载所需软件的源码进行配置 mkdir nginx-srccd nginx-srcwget http://n...

红薯
35分钟前
62
0
0228 我的潘多拉

我的潘多拉 从一个故事说起。<br />从前,有个Java程序员非常喜欢写程序,喜欢研究源码,读英文文档。但是它在一家小公司里工作,公司的技术栈很陈旧。<br /> <br />单个系统代码中含有很多的...

李福春carter
今天
18
0
OSChina 周六乱弹 —— 屁会不会传染病毒

Osc乱弹歌单(2020)请戳(这里) 【今日歌曲】 @薛定谔的兄弟 :分享洛神有语创建的歌单「我喜欢的音乐」: 《ハレハレヤ(朗朗晴天)》- 猫瑾 手机党少年们想听歌,请使劲儿戳(这里) @空格...

小小编辑
今天
77
1

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部