- 论坛徽章:
- 0
|
dali 内存数据库系统结构
3.5 Ping-pong Checkpointing
Checkpointing ensures that only a final portion of the log is needed for recovery. To implement checkpointing in Dalí, two copies of the database image are stored on disk, and alternate checkpoints write dirty pages to alternate copies. This strategy(策略) is called ping-pong checkpointing (see, for example, Salem and Garcia-Molina3). The ping-pong checkpointing strategy permits a checkpoint being created to be temporarily inconsistent, that is, updates may have been written out before corresponding undo records have been written. After dirty pages are written out, however, a sufficient amount of redo and undo log information is written out to bring the checkpoint to a consistent state. If a failure occurs while one checkpoint is being created, the other checkpoint is still consistent and can be used for recovery.
检查点确认只有最后一部分日志需要进行恢复。为了在Dalí中实现检查点,数据库的两个影像被保存在磁盘上。这个策略叫做乒乓检查点(例如Salem and Garcia-Molina3)。乒乓检查点允许检查点在不一致的情况下临时创建。就是说,在相应的UNDO日志写出前更新可以被写出,然而在脏页表写出后,足够的REDO和UNDO日志信息被写到磁盘上,保证检查处于一个一致的状态。当在检查点创建的过程中产生系统失败,那么其它检查点仍然处于一致恹并可以用于恢复。
Before writing any dirty data to disk, the checkpoint notes the current end of the stable log in the variable end_of_stable_log , which will be stored with the checkpoint. This variable indicates where to start scanning the system log to recover from a crash. Next, the contents of the (in-memory) ckpt_dpt are set to those of the dpt , and the dpt is zeroed (noting of end_of_stable_log and zeroing of dpt are performed atomically with respect to flushing). The pages written out are those that were either dirty in the ckpt_dpt of the last completed checkpoint, or dirty in the current (in-memory) ckpt_dpt , or both. In other words, all pages that were modified since the current checkpoint image was last written, namely, pages that were dirtied since the last-but-one checkpoint, are written out. This ensures that updates described by log records preceding the current checkpoint's end_of_stable_log are included in the database image in the current checkpoint.
在写任何脏数据到磁盘前,检查点用变量end_of_stable_log标志当胶可靠日志的结束,这与检查点一起保存。这个变量表明在系统崩溃后恢复时应该从什么地方开始扫描日志,然后内存中的ckpt_dpt内容被设置成dpt内容,dpt内容被清0(在刷新到磁盘上时标志end_of_stable_log和把dpt清0是一个原子操作)。被写到磁盘上的页面是那些自从上次检查点后在ckpt_dpt中为脏的页面,或是在当前内存中ckpt_dpt中为脏的页面,或两者都是。换句话说,从当前检查点后,在上一次写回磁盘后,所有被修改的页面被写回磁盘。这确认日志记录中的更新在当前检查点的end_of_stable_log前,被当前检查点的数据库映象包括。
Checkpoints write out dirty pages without obtaining any latches and do not, therefore, interfere with normal operations. This fuzzy checkpointing is possible because physical-redo log records are generated by all updates; these are used during restart recovery and their effects are idempotent[幂等的]. After the database image has been written, undo log records are written out to disk for any uncommitted update whose effects have made it to the checkpoint image. This is performed by checkpointing the ATT after checkpointing the data; the checkpoint of the ATT writes out undo log records, as well as some other status information.
检查点写出的脏页表不包含任何锁,因此不干扰当前任何操作。因为物理REDO日志被所有的更新产生,它们在重起后的恢复中被使用,他们的影响是幂等的,所以这种模糊检查点是可行的。在数据库映象被写出后,其它未提交的更新的UNDO日志记录被写出,因为它们已影响了检查点映象。在对数据执行检查点完后在对ATT执行检查点时执行,对ATT执行检查点时写出UNDO日志记录,同时也会写出一些其它的状态信息。
After checkpointing is performed, a log flush must be done before declaring the checkpoint completed (and consistent) by toggling cur_ckpt to point to the new checkpoint. Undo logs are deleted on transaction or operation pre-commit, which may happen before the checkpoint of the ATT. If the checkpoint completes but the system fails before a log flush, the checkpoint may contain uncommitted updates for which no undo information exists. The log flush ensures that the transaction or operation has committed, so the updates will not have to be undone (except perhaps by a compensating operation, for which undo information will be present in the log).
在检查点执行完后,日志刷新必须在定义检查点完成前完成,(并一致性)通过把cur_ckpt指向新检查点。UNDO日志在事务或操作预提交时被删除,这可能出现在对ATT执行检查点前。如果检查点完成但是系统在刷新日志前崩溃,检查点可能会包含没有UNDO信息的未完成的更新,日志刷新确认更务或更新已提交,因此更新不必进行UNDO(除了对那些日志中包含UNDO信息的记录对可能通过补偿操作) |
|