[20220223]bbed ktbbh.ktbbhict.txt

lfree發表於2022-02-25

[20220223]bbed ktbbh.ktbbhict.txt

--//bbed讀取資料塊時對於資料塊的ktbbh.ktbbhict應該記錄的是ITL槽的數量.可以我遇到不是這樣的情況,做一個記錄.

1.環境:
SCOTT@book> @ ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

2.分析:

SCOTT@book> select rowid from dept where rownum=1;
ROWID
------------------
AAAVRCAAEAAAACHAAA

SCOTT@book> @ rowid AAAVRCAAEAAAACHAAA
    OBJECT       FILE      BLOCK        ROW ROWID_DBA            DBA                  TEXT
---------- ---------- ---------- ---------- -------------------- -------------------- ----------------------------------------
     87106          4        135          0  0x1000087           4,135                alter system dump datafile 4 block 135 ;

BBED> p dba 4,135 ktbbh
struct ktbbh, 72 bytes         @20
   ub1 ktbbhtyp                @20  0x01 (KDDBTDATA)  --塊型別。1為表,2為索引
   union ktbbhsid, 4 bytes     @24                    --段或者物件的ID,也就是下邊的0x00015442 = 87106
      ub4 ktbbhsg1             @24  0x00015442        --段號
      ub4 ktbbhod1             @24  0x00015442        --物件號
   struct ktbbhcsc, 8 bytes    @28                    --最後一次塊清除的SCN
      ub4 kscnbas              @28  0x000e0ee4        --SCN base
      ub2 kscnwrp              @32  0x0000            --SCN wrap
   sb2 ktbbhict                @36  7938              --Number of ITL slots,注我不知道當前7838表示什麼,我看一些表確實等於ITL數量.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
   ub1 ktbbhflg                @38  0x32 (NONE)       --0 = ON THE FREELIST
   ub1 ktbbhfsl                @39  0x00              --ITL TX FREELIST SLOT
   ub4 ktbbhfnx                @40  0x01000080        --下一個空閒塊的地址 dba(DBA of next block on the freelist)
                                                      --//0x01000080 = set dba 4,128 = alter system dump datafile 4 block 128 = 16777344
....

--//你可以發現ktbbhict記錄的是7938. 7938 = 0x1f02,視乎後面的1個位元組才表示ITL槽數量.

3.繼續測試:
BBED> set dba 4,135
        DBA             0x01000087 (16777351 4,135)

BBED> verify
DBVERIFY - Verification starting
FILE = /mnt/ramdisk/book/users01.dbf
BLOCK = 135

BBED> assign ktbbh.ktbbhict=0x02
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
sb2 ktbbhict                                @36       2

BBED> sum apply
Check value for File 4, Block 135:
current = 0xcd93, required = 0xcd93

BBED> verify
DBVERIFY - Verification starting
FILE = /mnt/ramdisk/book/users01.dbf
BLOCK = 135
--//可以發現修改0x02(該塊2個ITL槽),verify也可以透過.

BBED> assign ktbbh.ktbbhict=0x03
sb2 ktbbhict                                @36       3

BBED> sum apply
Check value for File 4, Block 135:
current = 0xcd92, required = 0xcd92

BBED> verify
DBVERIFY - Verification starting
FILE = /mnt/ramdisk/book/users01.dbf
BLOCK = 135

Block Checking: DBA = 16777351, Block Type = KTB-managed data block
data header at 0xb469e4
kdbchk: avsp bad (21582)
Block 135 failed with check code 6126
--//ITL槽數量不對,肯定報錯,因為要透過它確定後面結構的開始偏移.

BBED> assign ktbbh.ktbbhict=0x1002
sb2 ktbbhict                                @36       4098

BBED> sum apply
Check value for File 4, Block 135:
current = 0xdd93, required = 0xdd93

BBED> verify
DBVERIFY - Verification starting
FILE = /mnt/ramdisk/book/users01.dbf
BLOCK = 135

--//可以發現這樣修改也可以透過.前面1個位元組不知道表示.總之只要後面位元組對應ITL數量就可以透過verify.
--//這個問題是以前學習的疑惑,做一個記錄.

--//盲掃看看.
$ seq 129 1 51201 | xargs -IQ echo "p /x dba 4,Q ktbbh.ktbbhict" | rlbbed > /tmp/aa.txt

$ grep ktbbhict   /tmp/aa.txt | sort|uniq -c
     32 BBED> sb2 ktbbhict                                @36       0x1
      2 BBED> sb2 ktbbhict                                @36       0x1002
      4 BBED> sb2 ktbbhict                                @36       0x1003
      3 BBED> sb2 ktbbhict                                @36       0x1202
      1 BBED> sb2 ktbbhict                                @36       0x1302
      2 BBED> sb2 ktbbhict                                @36       0x1502
      3 BBED> sb2 ktbbhict                                @36       0x1602
      2 BBED> sb2 ktbbhict                                @36       0x1702
      1 BBED> sb2 ktbbhict                                @36       0x1703
      2 BBED> sb2 ktbbhict                                @36       0x1802
      1 BBED> sb2 ktbbhict                                @36       0x1902
      3 BBED> sb2 ktbbhict                                @36       0x1a02
      1 BBED> sb2 ktbbhict                                @36       0x1b03
      2 BBED> sb2 ktbbhict                                @36       0x1c02
      1 BBED> sb2 ktbbhict                                @36       0x1c03
    887 BBED> sb2 ktbbhict                                @36       0x1d02
     96 BBED> sb2 ktbbhict                                @36       0x1e02
      3 BBED> sb2 ktbbhict                                @36       0x1e03
   2420 BBED> sb2 ktbbhict                                @36       0x1f02
     80 BBED> sb2 ktbbhict                                @36       0x1f03
  16626 BBED> sb2 ktbbhict                                @36       0x2
  29789 BBED> sb2 ktbbhict                                @36       0x3
      1 BBED> sb2 ktbbhict                                @36       0x602
      2 BBED> sb2 ktbbhict                                @36       0x702
      2 BBED> sb2 ktbbhict                                @36       0x802
      2 BBED> sb2 ktbbhict                                @36       0xa02
      2 BBED> sb2 ktbbhict                                @36       0xa9
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      2 BBED> sb2 ktbbhict                                @36       0xb02
      2 BBED> sb2 ktbbhict                                @36       0xf02
     12 BBED> sb2 ktbbhict                                @36       0xfffffffffffff802
      8 BBED> sb2 ktbbhict                                @36       0xffffffffffffff02

--//出現幾個比較怪異的情況.0xfffffffffffff802,0xffffffffffffff02,另外注意下劃線0xa9 = 169,這是我測試ITL最大數量的情況.
--//檢視log.bbd檔案(注bbed執行的記錄檔案),可以發現:

BBED> p /x dba 4,49592 ktbbh.ktbbhict
sb2 ktbbhict                                @36       0xfffffffffffff802

BBED> p /x dba 4,49864 ktbbh.ktbbhict
sb2 ktbbhict                                @36       0xffffffffffffff02

SYS@book> @ which_obj 4 49592
no rows selected

SYS@book> @ which_obj 4 49864
no rows selected

--//分析其中dba=4,49592的情況.
BBED> p dba 4,49592 ktbbh
struct ktbbh, 72 bytes                      @20
   ub1 ktbbhtyp                             @20       0x01 (KDDBTDATA)
   union ktbbhsid, 4 bytes                  @24
      ub4 ktbbhsg1                          @24       0x000507e1
      ub4 ktbbhod1                          @24       0x000507e1
   struct ktbbhcsc, 8 bytes                 @28
      ub4 kscnbas                           @28       0x1dbbd2c4
      ub2 kscnwrp                           @32       0x0003
   sb2 ktbbhict                             @36      -2046
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   ub1 ktbbhflg                             @38       0x32 (NONE)
   ub1 ktbbhfsl                             @39       0x00
   ub4 ktbbhfnx                             @40       0x0100c081
--//恩,負數.
BBED> dump /v dba  4,49592 offset 36 count 2
 File: /mnt/ramdisk/book/users01.dbf (4)
 Block: 49592   Offsets:   36 to   37  Dba:0x0100c1b8
-------------------------------------------------------
 02f8                                l ..

 <16 bytes per line>
--//也就是真實的值是f802,oracle當作負數顯示,在16進位制顯示時變成如上格式.估計是bbed的bug.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2857828/,如需轉載,請註明出處,否則將追究法律責任。

相關文章