数据库的事务、调度、可串行调度、冲突可串行化调度和可恢复调度

Transaction

Definition:

  • A transaction is a unit of program execution that accesses and possibly updates various data items
  • For example, transfer money from one account to another

ACID Properties:

  1. Atomicity 原子性

    Either all operations of the transaction are properly reflected in the database, or none are. Ensuring atomicity is the responsibility of the recovery system.

  2. Durability 持久性

    After a transaction completes, the changes it has made to the database persist, even if there is a system failure. Ensuring durability is the responsibility of the recovery system.

  3. Isolation 隔离性

    The intermediate inconsistent states from other concurrently executed transactions must be hidden. Ensuring isolation is the responsibility of the concurrency control system.

  4. Consistency 一致性

    If a transaction is run atomically in isolation starting from a consistent database, the database must again be consistent at the end of the transaction. Ensuring consistency is the responsibility of the application programmer.

Schedules 调度

specify the order in which instructions of concurrent transactions are executed

Serial Schedule 串行调度

The transactions execute one by one, without interleaving

Serializability 可串行化调度

A schedule is serializable if it is equivalent to a serial schedule.
即:如果一个调度能够与某个串行调度等价,它就是“可串行化”的,也叫“可串行化调度”

Order of Instructions
  1. If I and J access the same data item

    If I=read(Q), J=read(Q), then the order of I and J does not matter
    If I=read(Q), J=write(Q), then their order matters
    If I=write(Q), J=read(Q), then their order also matters
    If I=write(Q), J=write(Q), then their order also matters

  2. We say that I and J conflict if they access the same data item and at least one of them is a write operation

Conflict Serializability 冲突可串行化

We say that a schedule S is conflict serializable (冲突可串行化) if it is conflict equivalent to a serial schedule
即:如果把一个调度S中的不冲突命令调换位置后,可得到一个串行调度,那么这个调度S是“冲突可串行化”

区别:

  1. Serial schedule 串行调度

    the transactions execute one by one, without interleaving

  2. Serializable schedule 可串行调度

    equivalent to a serial schedule

  3. Conflict serializable schedule 冲突可串行调度

    conflict equivalent to a serial schedule

Recoverable Schedules 可恢复调度

For each pair of transactions X and Y,
if Y reads a data item previously written by X, then Y must commit after X has committed
即:如果 Y 读了 X 修改过的数据,那么在 X 提交后,Y 才能提交

Cascadeless Schedules 无连锁回滚调度

For each pair of transactions X and Y ,
if Y reads a data item previously written by X,
then Y must read after X has committed
在 X 提交后,Y 才能读 X 修改过的数据

无连锁回滚调度一定是可恢复调度

  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值