T5
Checkpoints
Overview
advatages of chekpoints:
- faseter recovery
- less space for log-file
Simple Checkpointing(for undo logging)
- 在日志中记录checkpoint_start (T1,T2…Tn) (Tx代表做checkpoint时,正在进行还未COMMIT的事务)
- 等待所有正在进行的事物 commit
- 在日志中记录checkpoint——end
借助checkpoint进行回滚·
从后往前扫描undo log
- 如果先遇到checkpoint_start, 则将checkpoint_start之后的所有未提交的事务进行回滚;
- 如果先遇到checkpoint_end, 则将前一个checkpoint_start之后所有未提交的事务进行回滚;(在checkpoint的过程中,可能有很多新的事务START或者COMMIT)。

Recovery via Simple Checkpoints


ARIES Checkpoints

Recovery via ARIES Checkpoints

Being able to recover
Conflict-Serialissability vs Recovery

No good solutions to the problem

Dirty Reads

Cascading Rollback

Isolation vs Durability

Recoverable Schedules
Can still do cascadinng rollbacks, but only active transactions can be forced to abort

Example

Recoverable Schedules - implicit assumption(隐含假设)

No cascading-rollbacks!
Overview
Cascadeless schedules
Recover schedules still cascades

Cascadeless Schedules


Example

Cascadeless Schedules: Properties

Can cascading Aborts & Serialisability both?
Strict Schedules
A schedule is strict if each transaction in it reads and writes only values that were written by transaction that have already committed
如果调度中的每个事务只读取和写入已经提交的事务写入的值,则调度是严格的


Strict Two-phase Locking(Strict 2PL)

Example



Strict Two-Phase Locking Enforces Conflict-Serialisable & strict Schedules

How the Typs of Schedules are Related

Example for serializable schedules

Still … Risk of Deadlocks

Strict 2PL and Deadlocks

Detecting deadlocks
Strict 2PL and Deadlocks

Deadlock Detection: Approaches

Timestamps for Deadlock Detection

How Are Timestamps Used

Wait-Die Scheme

Wound-Wait Scheme



Timestamp based schedules
Deadlock prevention
Two approaches for deadlock prevention:
- Detect deadlock & fix them
- Enforce deadlock-free schedules
Basic Idea
计划事务,以便其效果与在每个事务启动时立即执行相同。
Timestamp-Based Schedulers

Timestamps
