checkpoint queue 和 write list

来源:互联网 发布:国学播放器软件 编辑:程序博客网 时间:2024/06/06 14:02

checkpoint queue 和 write list



在oracle中存在 dirty list(也就是write list)的说法,但是同时又有checkpoint queue 。这两个东西往往让人容易混淆。他们是同一个东西吗?之间关系如何?

在阐述之前,我们先来看一段大师的描述

http://www.ixora.com.au/q+a/0103/07160329.htm

That information is not quite right. It is more accurate to say that there are 10 lists, because there are 5 types of buffers and there is a MAIN and AUXILIARY list for each type. Also, there is no separate hot list. The hot list is a sublist of the main replacement list. Of course, there are separate lists for each working set (LRU latch set) of buffers.

You can see all these structures in BUFFERS dumps. Here is an extract ...

(WS) size: 10000 wsid: 1 state: 0 (WS_REPL_LIST) main_prev: 32aefbc main_next: 32ae51c aux_prev: 32c94a0 aux_next: 32c94a0 curnum: 10000 auxnum: 0 cold: 32a307c hbmax: 5000 hbufs: 5000 (WS_WRITE_LIST) main_prev: 32c94b4 main_next: 32c94b4 aux_prev: 32c94bc aux_next: 32c94bc curnum: 0 auxnum: 0 (WS_PING_LIST) main_prev: 32c94d0 main_next: 32c94d0 aux_prev: 32c94d8 aux_next: 32c94d8 curnum: 0 auxnum: 0 (WS_XOBJ_LIST) main_prev: 32c94ec main_next: 32c94ec aux_prev: 32c94f4 aux_next: 32c94f4 curnum: 0 auxnum: 0 (WS_XRNG_LIST) main_prev: 32c9508 main_next: 32c9508 aux_prev: 32c9510 aux_next: 32c9510 curnum: 0 auxnum: 0


Other than the replacement lists, the other lists are for different types of write buffers. From the bottom up they are buffers that have to be written for a checkpoint range call, a checkpoint object call, a ping, or merely because they are dirty. In each case the main list holds buffers which have yet to be written, and the auxiliary list holds buffers for which a write is pending. The auxiliary replacement list holds unpinned buffers for which a write has been completed, and any other buffers that are immediately reusable. The main replacement list is what is commonly called the LRU list. The operation of the LRU list was explained under the heading The 8i buffer cache in the October issue of Ixora News. You may also be interested in the section on DBWn's new tricks in the September issue.

These 10 lists are mutually exclusive. Each buffer can only be on one of the lists at a time. For completeness it should also be mentioned that dirty buffers are also on a thread checkpoint queue and a file checkpoint queue. These queues are maintained in first modification (low RBA) order and are used to optimize checkpoint processing.

也就是说,在oracle 8 中,buffer cache 中实际存在着5大类lists,加辅助的lists共10小类。其中的4大类(8小类lists)统称write list。他们记录了dirty buffer 的各种状态信息。而通常的LRU list 只有一个大类,实际共两小类lists。也就是 replacement lists 。实际上,在9i开始版本,lists又有所增加,大致是12小类lists,这里就不过多的阐述了。(注意这里都说的是类而不是条数,因为条数实际上和 db_block_lru_latches参数有关,9i中这是隐藏参数)

在4大类的write lists 中,记录了buffer的状态(they are buffers that have to be written for a checkpoint range call, a checkpoint object call, a ping, or merely because they are dirty) 。由于write lists 中的buffer 的状态可能是转换的,也是没有时间顺序的,也就是说,如果按照这个lists写buffer到磁盘,其顺序和buffer变化发生的时间顺序并不是一致的。这也直接造成在oracle 8以前版本中,检查点都是 完全刷新 dirty buffer 的,也就是说检查点发生的时候,所有dirty buffer都要被写入磁盘,而且这个时候是不能有dirty buffer产生的,否则oracle将无法知道是否将所有的检查点时刻之前的dirty buffer 都写入了磁盘。

从oracle 8开始,出现了checkpoint queue 。checkpoint queue 是按照buffer的 low RBA 排序的,也就是说按照buffer 第一次发生变化的时候的时间点排序的。同一个dirty buffer ,既存在与 write lists中(记录着buffer的状态)又存在于checkpoint queue 中,记录着buffer 第一次发生变化的时间顺序。这样dbwr根据checkpoint queue中顺序写出dirty buffer 就一定能保证是按照 buffer 首次发生变化的时间顺序写到磁盘的。这样的一个机制,就支持了oracle的增量检查点的功能的实现。也就是说,当增量检查点发生的时候,只确定写的buffer的结束时间点,在这个检查点过程中,可以继续产生dirty buffer,dbwr也不是一次要把 所有dirty buffer 全部写到磁盘。这样大大地提高了检查点的效率。

实际上,checkpoint queue 与 write list 的配合,更是可以在实现增量检查点的同时模拟异步IO。这个问题就留待以后进行讨论了。

 

关于checkpoint的更多的内容,请参考

http://blog.csdn.net/biti_rainy/archive/2004/07/12/learn_oracle_20040712_1.aspx


 

0 0