An Introduction to Database System
数据库原理
Principles of Database
第十一章并发控制
1
An Introduction to Database System
飞机定票系统
2
An Introduction to Database System
银行数据库系统
3
An Introduction to Database System
第十一章并发控制
为何要并发?
并发执行可能引起哪些问题?
如何知道并发执行后结果是正确的?
并发执行如何控制实现?
4
An Introduction to Database System
第十一章并发控制
并发控制概述
封锁
活锁和死锁
并发调度的可串行性
两段锁协议
封锁的粒度
小结
5
An Introduction to Database System
多事务执行方式
事务串行执行
每个时刻只有一个事务运行,其他事务必须等到这个事务结束以后方能运行
T1
T2
T3
6
An Introduction to Database System
多事务执行方式(续)
交叉并发方式(interleaved concurrency)
事务的并行执行是这些并行事务的并行操作轮流交叉运行
单处理机系统中的并发方式,能够减少处理机的空闲时间,提高系统的效率
T1
T2
T3
T1
T2
T1
T3
T3
T2
T2
T1
7
An Introduction to Database System
多事务执行方式(续)
同时并发方式(simultaneous concurrency)
多处理机系统中,每个处理机可以运行一个事务,多个处理机可以同时运行多个事务,实现多个事务真正的并行运行。
8
An Introduction to Database System
并发操作带来的数据不一致性
丢失修改(lost update)
读“脏”数据(dirty read)
不可重复读(non-repeatable read)
9
An Introduction to Database System
丢失修改
Time
T1
T2
A=16
读A=16
读A=16
A=A-1
写回A
A=15
A=A-1
写回A
A=15
A=15
10
第11章 并发控制-课件PPT(精) 来自淘豆网www.taodocs.com转载请标明出处.