跳转至

Recovery

约 392 个字 21 张图片 预计阅读时间 2 分钟

Failure Classification

image-20240612151527971

image-20240614141438208

事务的物理实现

image-20240614141933638

日志记录

image-20240614141623670

事务恢复

image-20240614142545583

一个事务的Commit标志:日志写入稳定存储器

A transaction is said to have committed when its commit log record is output to stable storage

  • All previous log records of the transaction must have been output already

这时的修改不一定写到了磁盘

立即修改

The immediate-modification scheme allows updates of an uncommitted transaction to be made to the buffer, or the disk itself, before the transaction commits

redo undo

  • redo 历史重演
  • undo 需要记录日志 redo-only,完成后,记录\
    • 正常执行过程中的回滚
    • 系统崩溃后恢复发现没有结束

Check Point

image-20240614143612811

fuzzy check point

image-20240614150924069

事务回滚

补偿日志记录

image-20240614143814771

缓冲区管理

image-20240614150207603

log force 将缓冲的日志强行写到Disk

image-20240614150540972

Logical Undo

Redo是按照物理执行

image-20240614152757110

image-20240614152909188

ARIES

  • 每个记录一个日志顺序号 LSN

Typically an offset from beginning of log file to allow fast access

  • 在数据页中记录一个LSN - Page LSN
    • 更新发生,日志的LSN记录进去
    • 防止 重复的 redo

image-20240614154435835

  • Log Record

image-20240614154636492

  • Special redo-only log record called compensation log record (CLR) used to log actions taken during recovery that never need to be undone

    • 在回滚时,有助于跳过已经回滚的日志
  • Physiological redo

  • Dirty Page Table

    • 在后台周期性写回,而不是在Check Point

记录脏页image-20240614155029448

  • Fuzzy Check Point

only records information about dirty pages, and does not require dirty pages to be written out at checkpoint time

image-20240614155331333

流程

image-20240614155635517

  • 分析

    • 得到redo的位置RedoLSN —— 至少在Check Point 之前,对脏页Table的Rec取Min
    • undo-list
      image-20240614155930834 从Check Point 往下扫描,完善undo list
    • 更新脏页表 image-20240614160001232
  • Redo

    • 脏页表,注意是跟log record中的LSN比较
    • 磁盘页
  • Undo

image-20240614160502406

image-20240614161912321