Skip to content

Commit 86b227c

Browse files
committed
增加锁相关内容
1 parent ab9e83b commit 86b227c

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

index.adoc

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ include::high-performance-index.adoc[]
2121

2222
include::query-optimization.adoc[]
2323

24+
include::locks.adoc[]
25+
2426
include::sharding.adoc[]
2527

2628
include::explain-in-detail.adoc[]

locks.adoc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[#locks]
2+
== 锁
3+
4+
* *共享锁 Shared Lock*,简称 S 锁
5+
* *独占锁 Exclusive Lock*,也称排他锁,简称 X 锁
6+
* *意向共享锁 Intention Shared Lock*,简称 IS 锁。当事务准备在某条记录上加 S 锁时,需要先在表级别加一个 IS 锁。
7+
* *意向独占锁 Intention Exclusive Lock*,简称 IX 锁。当事务准备在某条记录上加 X 锁时,需要先在表级别加一个 IX 锁。
8+
9+
NOTE: 意向共享锁 和 意向独占锁 并不是真正的锁,而是相当于一个公告牌。表示有记录被锁定了。避免在锁表(对表加 共享锁 或 独占锁 时去遍历全部记录。)

transaction.adoc

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ Repeatable Read(可重复读) 是 MySQL 默认事务隔离级别。
3737
. *不可重复读 NonRepeatable Read* -- 如果一个事务**修改**了另外一个未提交事务**读取**的数据,就意味着发生了不可重复读现象,或者叫模糊读 Fuzzy Read 现象。可以把不可重复读现象简称为 P2。
3838
. *幻读 Phantom* -- 如果一个事务先根据某些搜索条件查询出一些记录,在该事务**未提交时**,另一个事务**写入**了一些**符合那些搜索条件**的记录(CUD 任意一种),就意味着发生了幻读现象。可以把幻读现象简称为 P3。
3939

40-
TIP: 这里采用 https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/tr-95-51.pdf[《A Critique of ANSI SQL Isolation Levels》^] 论文中的定义。
41-
40+
TIP: 这里采用 https://arxiv.org/abs/cs/0701157[《A Critique of ANSI SQL Isolation Levels》^] 论文中的定义。
4241

4342

4443
==== Phantom Read(幻读)

0 commit comments

Comments
 (0)