关于Fast Block Cleanout

| No Comments

有多少朋友真正知道Fast Block Cleanout的含义?

 

我们来看一个Fast Block Cleanout的例子:

SQL> create table t1 as select * from dba_users;

 

Table created

 

SQL> alter system checkpoint;

 

System altered

 

SQL> select dump('_NEXT_OBJECT',16) from dual;

 

DUMP('_NEXT_OBJECT',16)

--------------------------------------------------

Typ=96 Len=12: 5f,4e,45,58,54,5f,4f,42,4a,45,43,54

 

BBED> set file 1

        FILE#           1

 

BBED> set block 122

        BLOCK#          122

 

BBED> dump

 File: /dras11/oradata/astca/system01.dbf (1)

 Block: 122              Offsets:    0 to  511           Dba:0x0040007a

------------------------------------------------------------------------

 06020000 0040007a aa05a584 00080106 b4720000 01000000 00000012 aa05a583

 00080000 00010200 00000000 0005001e 0001b684 0080004f 475c4500 20010000

 aa05a584 0001006c ffff00ea 0110035c 035c0000 006c1f7c 1f3c1efb 1ebe1e7e

 01101dec 1da41d64 1d221ce1 1ca41c5c 1c1b1bda 1b9f1b5f 1b1f1adf 1aa21a54

 1a1719db 199a1959 191218d1 1890184f 180e17cd 178d174c 170c16cf 168f1653

 161415d8 15981559 151d14d5 1499145a 141913d9 139d1361 131e12dd 129d1260

 122411e3 11a21163 112010dd 10a11065 10280fe5 0fa40f5f 0f1a0ede 0e9c0e56

 0e150dd6 0d960d55 0d150cd5 0c990c5b 0c1a0bd4 0b840b34 0af40ab1 0a750a39

 09f409af 096a0925 08e508a5 08650825 07e507a4 07610722 06e606a9 061f05df

 05a10559 051604cd 048b0449 04030000 00000000 00000000 00000000 00000000

 00000000 00000000 00000000 00000000 00000000 2c011102 c10204c3 093e3b01

 800c5f4e 4558545f 4f424a45 435402c1 02ff0180 07786a06 13042b28 07786d06

 03130a3c 07786a06 13042b28 0180ffff 0180ff01 8004c307 38242c00 1102c102

 03c26463 01800c5f 4e455854 5f4f424a 45435402 c102ff01 8007786a 0613042b

 2807786a 06130432 1207786a 0613042b 280180ff ff0180ff 018004c3 0738242c

 001102c1 0202c207 01800c5f 4e455854 5f4f424a 45435402 c102ff01 8007786a

 

 <32 bytes per line>

 

BBED> set offset 340

        OFFSET          340

 

BBED> dump

 File: /dras11/oradata/astca/system01.dbf (1)

 Block: 122              Offsets:  340 to  851           Dba:0x0040007a

------------------------------------------------------------------------

 2c011102 c10204c3 093e3b01 800c5f4e 4558545f 4f424a45 435402c1 02ff0180

 07786a06 13042b28 07786d06 03130a3c 07786a06 13042b28 0180ffff 0180ff01

 8004c307 38242c00 1102c102 03c26463 01800c5f 4e455854 5f4f424a 45435402

 c102ff01 8007786a 0613042b 2807786a 06130432 1207786a 0613042b 280180ff

 ff0180ff 018004c3 0738242c 001102c1 0202c207 01800c5f 4e455854 5f4f424a

 45435402 c102ff01 8007786a 0613042b 2807786a 0613042b 3507786a 0613042b

 280180ff ff0180ff 018004c3 0738242c 001102c1 0203c206 6401800c 5f4e4558

 545f4f42 4a454354 02c102ff 01800778 6a061304 2b280778 6a061304 2b350778

 6a061304 2b280180 ffff0180 ff018004 c3073824 2c001102 c10202c2 0601800c

 5f4e4558 545f4f42 4a454354 02c102ff 01800778 6a061304 2b280778 6a061304

 2b340778 6a061304 2b280180 ffff0180 ff018004 c3073824 2c001102 c10203c2

 05640180 0c5f4e45 58545f4f 424a4543 5402c102 ff018007 786a0613 042b2807

 786a0613 042b3407 786a0613 042b2801 80ffff01 80ff0180 04c30738 242c0011

 02c10202 c2050180 0c5f4e45 58545f4f 424a4543 5402c102 ff018007 786a0613

 042b2807 786a0613 042b2d07 786a0613 042b2801 80ffff01 80ff0180 04c30738

 242c0011 02c10203 c2046401 800c5f4e 4558545f 4f424a45 435402c1 02ff0180

 

 <32 bytes per line>

 

这里我们可以看出在obj$_NEXT_OBJECT所在的block上已经发生了一次Fast Block Cleanout

 

因为上述block中:

块头的SCNaa05a584 0008,其所在的SEQ01

CSCaa05a583 0008

SCN/FSC0000 aa05a584,即FSCFree space credit)为0000

Lck Flag20

这完全符合oracleFast Block Cleanout的特征!

 

Oracle在做Fast Block Cleanout之前会检查这个blockCSCwrap是否等于当前transactioncommit SCNwrap,只有在相等的情况下才会继续做下去。我们从上面可以看到现在的CSCwrap0008commit SCNwrap也是0008,即这个条件被满足。

 

Oracle在做Fast Block Cleanout的时候会做这样一些事情:

1) 会把ITL中的LCK Flag设为20

2) 会把当前transactioncommit scn写到这个block的块头的SCN,同时把seq写为1,当然,写的时候会判断一下,如果当前transactioncommit scn已经和块头的SCN相等了,就只递增seq

3) 会把当前transactioncommit scnbase写到ITL中,紧邻FSC

4) 这个block会被oraclebuffer cache中标记为dirty

 

oracle做完Fast Block Cleanout后,对应记录行头的lock flag并不会被清掉,并且ITL中的FSC不会被修改(所以oracle只会把commit scnbase写到ITL中)----我们从结果中可以看到_NEXT_OBJECT所在记录的行头的lock flag还是01,这时候ITL中的FSC还是0000,且commit scnbase(即aa05a584)已经被写到上述ITL中。

 

朋友们,当你见到ITL中的Lck Flag20的时候,就代表着oracle已经对这个block成功做过Fast Block Cleanout了,这个ITL所对应的transaction已经commit了!

Leave a comment