ITPub博客

首页 > 数据库 > Oracle > [20220223]bbed ktbbh.ktbbhict.txt

[20220223]bbed ktbbh.ktbbhict.txt

原创 Oracle 作者:lfree 时间:2022-02-25 15:28:58 0 删除 编辑

[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博客 ” ,链接:https://blog.itpub.net/267265/viewspace-2857828/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4006
  • 访问量
    7971267