redo log + undo log一起上

undo logging
redo logging各有优缺点,一个需要频繁flush to disk, 一个需要较大的buffer.

如何同时避免这两种缺点?让buffer manager按最佳性能策略决定何时flush, 而不必考虑log的问题。

办法就是redo log + undo log一起上. 对于每个数据改动,记录 <Transaction T, 数据X, 旧值,新值>.

唯一的约束是,在将数据改动flush至disk之前,保证相应的log entry已经写至disk.

数据恢复时,把commited transaction全部redo一遍,再把incomplete transaction全部undo一遍。

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.