事务隔离级别定义
操作冲突
: 两个不同事务对同一个数据项进行操作,且至少一个为write操作,则这两个操作是冲突操作。
等价调度
: 不存在冲突的操作可以进行执行顺序的交换,交换后的结果与交换前效果是一致的,称为等价调度。
可串行化
: 并发执行的事务操作顺序,通过等价调度,可以得到与顺序执行相同的调度,则称为事务是可串行化的。
隔离级别对应的3个现象:
- 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.
- 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.
- 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.
对应的宽泛解释和实际解释:
|
|
隔离级别和现象的对应关系:
串行化的定义前面已经讲过了,排出P1,P2,P3三种现象并不是串行化的实际定义。