MySQL Shared and Exclusive Locks
InnoDB
implements standard row-level locking where there are two types of locks, shared (S
) locks and exclusive (X
) locks.
A shared (
S
) lock permits the transaction that holds the lock to read a row.An exclusive (
X
) lock permits the transaction that holds the lock to update or delete a row.
If transaction T1
holds a shared (S
) lock on row r
, then requests from some distinct transaction T2
for a lock on row r
are handled as follows:
A request by
T2
for anS
lock can be granted immediately. As a result, bothT1
andT2
hold anS
lock onr
.A request by
T2
for anX
lock cannot be granted immediately.
If a transaction T1
holds an exclusive (X
) lock on row r
, a request from some distinct transaction T2
for a lock of either type on r
cannot be granted immediately. Instead, transaction T2
has to wait for transaction T1
to release its lock on row r
.
shared lock
A kind of lock that allows other transactions to read the locked object, and to also acquire other shared locks on it, but not to write to it.
exclusive lock
A kind of lock that prevents any other transaction from locking the same row. Depending on the transaction isolation level, this kind of lock might block other transactions from writing to the same row, or might also block other transactions from reading the same row. The default InnoDB isolation level, REPEATABLE READ, enables higher concurrency by allowing transactions to read rows that have exclusive locks, a technique known as consistent read.
MySQL Shared and Exclusive Locks的更多相关文章
- Shared and Exclusive Locks 共享和排它锁
14.5 InnoDB Locking and Transaction Model InnoDB 锁和事务模型 14.5.1 InnoDB Locking 14.5.2 InnoDB Transact ...
- If one session has a shared or exclusive lock on record R in an index, another session cannot insert
If one session has a shared or exclusive lock on record R in an index, another session cannot insert ...
- mysql锁之Next-Key Locks
一个Next-key锁结合了行锁和gap锁. InnoDB执行一个行级别锁在这样的一个途径,那就是它搜索或者扫描一个表索引时,它设置共享或者独占锁在它遭遇的索引记录上.于是,行级锁是真实的行记录锁.一 ...
- 转 MYSQL InnoDB Record, Gap, and Next-Key Locks
http://dev.mysql.com/doc/refman/5.0/en/innodb-record-level-locks.html InnoDB has several types of re ...
- 小白学习mysql 之 innodb locks
Innodb 锁类型: Shared and Exclusive Locks Intention Locks Record Locks Gap Locks Next-Key Locks Insert ...
- Mysql讲解数据库并发控制知识
1.下载Mysql并安装,我喜欢不用安装的zip版,cd到bin目录下,先修改下mysql的密码. mysqladmin -u root -p password mysql ,第一次运行并修改mysq ...
- 14.3.3 Locks Set by Different SQL Statements in InnoDB 不同的SQL语句在InnoDB里的锁设置
14.3.3 Locks Set by Different SQL Statements in InnoDB 不同的SQL语句在InnoDB里的锁设置 locking read, 一个UPDATE,或 ...
- mysql锁机制详解
前言 大概几个月之前项目中用到事务,需要保证数据的强一致性,期间也用到了mysql的锁,但当时对mysql的锁机制只是管中窥豹,所以本文打算总结一下mysql的锁机制. 本文主要论述关于mysql锁机 ...
- 转 mysql Next-Key Locking
原文:http://dev.mysql.com/doc/refman/5.5/en/innodb-next-key-locking.html 14.5.2.5 Avoiding the Phantom ...
随机推荐
- zabbix--4.0源码安装
Zabbix4.0 源码编译安装 ps:其实相对 zabbix 来说,直接按照官网 yum 安装还是要方便点,我这里已经有 lnmp 的环境了,就想自己编译安装试下. 官网yum安装中文文档:http ...
- Python 基础-> 字符串,数字,变量
Python 基础:字符串,数字,变量 1. 字符串 (信息的一种表达方式) a. 使用引号创建字符串 b. 单引号,双引号,三引号: ', ", ''', ""&quo ...
- 用Photoshop软件实现批量压缩照片
前提:手头有 "大" 照片,出于某种原因想把它变成 "小" 照片:电脑刚好安装有PS软件. 需知:如果您的压缩需求仅限于降低图片品质,降低图片像素,那么建议您采 ...
- BFS (1)算法模板 看是否需要分层 (2)拓扑排序——检测编译时的循环依赖 制定有依赖关系的任务的执行顺序 djkstra无非是将bfs模板中的deque修改为heapq
BFS模板,记住这5个: (1)针对树的BFS 1.1 无需分层遍历 from collections import deque def levelOrderTree(root): if not ro ...
- Win10系统如何关闭自动更新?
现在很多电脑的系统都升级到了win10了,win10已经渐渐普及到每个人的电脑中,但是,win10系统有一个功能特别讨人厌,我自认为挺讨厌这个功能的,它就是“自动更新”功能,你可能会说,自动更新不是挺 ...
- 使用ArcGIS for Server的Feature Access REST在线编辑图层
如何启用Feature Access可以参考以前写的一篇博客:http://www.cnblogs.com/oceanking/p/3895257.html 本文主要关注一个全是点的图层,我也不知道学 ...
- 项目Beta冲刺(团队)--2/7
课程名称:软件工程1916|W(福州大学) 作业要求:项目Beta冲刺 团队名称:葫芦娃队 作业目标:进行新一轮的项目冲刺,尽力完成并完善项目 团队博客 队员学号 队员昵称 博客地址 04160242 ...
- python基础语法3 元组,字典,集合
元组: ========================元组基本方法===========================用途:存储多个不同类型的值定义方式:用过小括号存储数据,数据与数据之间通过逗号 ...
- 小程序开发二三事--数据请求head的设置
wx.request(OBJECT) 发起请求的方法有很多,默认为 GET,有效值:OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT: 一般在 ...
- codeforces B. A and B 找规律
Educational Codeforces Round 78 (Rated for Div. 2) 1278B - 6 B. A and B time limit per test 1 secon ...