日期:2014-05-16  浏览次数:20555 次

Oracle dirty block的一些探讨(三)
继续前面的话题:
如果block在buffer cache中发生了变化(也就意味着dirty block),执行alter system flush buffer_cache会将此block刷新至数据文件
当磁盘的block scn大于buffer cache中block scn时,刷出动作是否也会进行?Oracle buffer cache刷出至datafile时,是否会做scn判断。
用bbed修改block scn高4位,从000a修改至000b,确保datafile block scn大于buffer cache block scn。
BBED> modify 0x000b
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /oradata/mcstar/zhoul01.dbf (0)
Block: 15511            Offsets:   12 to  523           Dba:0x00000000
------------------------------------
000b0206 b06b0000 01002900 36160200 36640908 000ae81f 021f3200 913cc001
05002b00 750c0000 12048000 32051000 0080000a 77570908 07002c00 df0b0000
b02c8000 b7020300 01200000 3f640908 00000000 00000000 00010300 ffff1800
7a1f621f 621f0000 03008e1f 841f7a1f 311fff1e cb1e5c1e 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

<32 bytes per line>

BBED> sum apply
Check value for File 0, Block 15511:
current = 0x6ab0, required = 0x6ab0

观察目前在datafile字段依然为797979,转换成字符串就是yyy。
BBED> dump offset 8185
File: /oradata/mcstar/zhoul01.dbf (0)
Block: 15511            Offsets: 8185 to 8191           Dba:0x00000000
------------------------------------
79797902 063f64

<32 bytes per line>

在内存中可以字段也依然为yyy
SQL> select * from zhoul;

         I NAME
---------- --------------------
         1 yyy
         2 bbb
         3 ccc
在buffer cache中将yyy改为xxx,也就意味着15511为dirty block。
SQL> update zhoul set name='xxx' where name='yyy';

1 row updated.

SQL> commit;    

Commit complete.

SQL> alter system flush buffer_cache;

System altered.
将其刷出buffer cache之后,再次读取业务表格zhoul,可以看到name列为xxx,并不是之前物理上修改的yyy
SQL>  select * from zhoul;

         I NAME
---------- --------------------
         1 xxx
         2 bbb
         3 ccc

在物理上也看到是xxx
BBED> dump block 15511 offset 8185
File: /oradata/mcstar/zhoul01.dbf (0)
Block: 15511            Offsets: 8185 to 8191           Dba:0x00000000
------------------------------------
78787802 062e88

<32 bytes per line>

经过以上测试,我们可以推出以下结论: