A Critique of ANSI SQL Isolation Levels

事务隔离级别定义

操作冲突: 两个不同事务对同一个数据项进行操作,且至少一个为write操作,则这两个操作是冲突操作。

等价调度: 不存在冲突的操作可以进行执行顺序的交换,交换后的结果与交换前效果是一致的,称为等价调度。

可串行化: 并发执行的事务操作顺序,通过等价调度,可以得到与顺序执行相同的调度,则称为事务是可串行化的。

隔离级别对应的3个现象:

  1. Dirty Read

Transaction T1 modifies a data item. Another transaction T2 then reads that data item before T1 performs a COMMIT or ROLLBACK. If T1 then performs a ROLLBACK, T2 has read a data item that was never committed and so never really existed.

  1. Non-repeatable or Fuzzy Read

Transaction T1 reads a data item. Another transaction T2 then modifies or deletes that data item and commits. If T1 then attempts to reread the data item, it receives a modified value or discovers that the data item has been deleted.

  1. Phantom

Transaction T1 reads a set of data items satisfying some . Transaction T2 then creates data items that satisfy T1’s and commits. If T1 then repeats its read with the same , it gets a set of data items different from the first read.

对应的宽泛解释和实际解释:

1
2
3
4
5
6
P1: w1[x]...r2[x]...((c1 or a1) and (c2 or a2) in any order)
A1: w1[x]...r2[x]...(a1 and c2 in any order)
P2: r1[x]...w2[x]...((c1 or a1) and (c2 or a2) in any order)
A2: r1[x]...w2[x]...c2...r1[x]...c1
P3: r1[P]...w2[y in P]...((c1 or a1) and (c2 or a2) any order)
A3: r1[P]...w2[y in P]...c2...r1[P]...c1

隔离级别和现象的对应关系:

ANSI SQL Isolation Levels Defined in terms of the Three Original Phenomena

串行化的定义前面已经讲过了,排出P1,P2,P3三种现象并不是串行化的实际定义。

本文标题:A Critique of ANSI SQL Isolation Levels

文章作者:Louis

发布时间:2017年11月30日 - 11:11

最后更新:2017年12月04日 - 13:12

原始链接:/2017/11/30/critique-ansi-sql-isolation/

许可协议: Louis-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。