ITPub博客

首页 > 数据库 > Oracle > [20210223]bbed itl ktbitflg 2.txt

[20210223]bbed itl ktbitflg 2.txt

原创 Oracle 作者:lfree 时间:2021-02-23 16:15:53 0 删除 编辑

[20210223]bbed itl ktbitflg 2.txt

--//简单探究bbed查看ITL槽的ktbitflg含义.它包含2部分信息占32位,前4位表示提交状态,后12位表示dml的记录数.

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> create table t as select rownum id from dual connect by level<=740;
Table created.
--//分析略.

SCOTT@book> select rowid,t.* from t where rownum=1;
ROWID                      ID
------------------ ----------
AAAWIjAAEAAAA2rAAA          1

SCOTT@book> @ rowid AAAWIjAAEAAAA2rAAA
    OBJECT       FILE      BLOCK        ROW ROWID_DBA            DBA                  TEXT
---------- ---------- ---------- ---------- -------------------- -------------------- ----------------------------------------
     90659          4       3499          0  0x1000DAB           4,3499               alter system dump datafile 4 block 3499

SCOTT@book> select max(id) from t where rowid <='AAAWIjAAEAAAA2rDDD';
     MAX(ID)
------------
         657
--//dba=4,3499占657条记录.

SCOTT@book> update t set id=id where id<=600;
600 rows updated.

SCOTT@book> @ xid
XIDUSN_XIDSLOT_XIDSQN
------------------------------
10.22.20803

SCOTT@book> alter system flush buffer_cache;
System altered.
--//保证该块不再数据缓存.

3.通过bbed观察:
BBED> p  dba 4,3499  ktbbh.ktbbhitl[1]
struct ktbbhitl[1], 24 bytes                @68
   struct ktbitxid, 8 bytes                 @68
      ub2 kxidusn                           @68       0x000a
      ub2 kxidslt                           @70       0x0016
      ub4 kxidsqn                           @72       0x00005143
   struct ktbituba, 8 bytes                 @76
      ub4 kubadba                           @76       0x00c001b8
      ub2 kubaseq                           @80       0x10d2
      ub1 kubarec                           @82       0x06
   ub2 ktbitflg                             @84       0x0258 (NONE)
   ~~~~~~~~~~~~~~~~~~~~~~ --//我没有提交,而且当前该块已经写盘.
   union _ktbitun, 2 bytes                  @86
      sb2 _ktbitfsc                         @86       0
      ub2 _ktbitwrp                         @86       0x0000
   ub4 ktbitbas                             @88       0x00000000

--//0x0258 = 600条.与操作事务记录数一致,并且没有提交.如果我提交不会修改该块(延迟块清除).而是下次select时修改写上.
--//0x00005143 = 20803 与前面看到xid信息也能对上.

SCOTT@book> commit ;
Commit complete.

SCOTT@book> select rowid,t.* from t where rownum=1;
ROWID                      ID
------------------ ----------
AAAWIjAAEAAAA2rAAA          1

SCOTT@book> alter system flush buffer_cache;
System altered.

--//再通过bbed观察:
BBED> p  dba 4,3499  ktbbh.ktbbhitl[1]
struct ktbbhitl[1], 24 bytes                @68
   struct ktbitxid, 8 bytes                 @68
      ub2 kxidusn                           @68       0x000a
      ub2 kxidslt                           @70       0x0016
      ub4 kxidsqn                           @72       0x00005143
   struct ktbituba, 8 bytes                 @76
      ub4 kubadba                           @76       0x00c001b8
      ub2 kubaseq                           @80       0x10d2
      ub1 kubarec                           @82       0x06
   ub2 ktbitflg                             @84       0x8000 (KTBFCOM)
   union _ktbitun, 2 bytes                  @86
      sb2 _ktbitfsc                         @86       3
      ub2 _ktbitwrp                         @86       0x0003
   ub4 ktbitbas                             @88       0x177275ce
--//下次读出时修改该事务槽的ktbitflg,并且清除了lck信息为0.

4.继续:
SCOTT@book> update t set id=id-1 where id<=500;
500 rows updated.

SCOTT@book> alter system checkpoint ;
System altered.

SCOTT@book> @ xid
XIDUSN_XIDSLOT_XIDSQN
------------------------------
10.17.20632

--//bbed观察:
BBED> p  dba 4,3499  ktbbh.ktbbhitl[1]
struct ktbbhitl[1], 24 bytes                @68
   struct ktbitxid, 8 bytes                 @68
      ub2 kxidusn                           @68       0x0003
      ub2 kxidslt                           @70       0x000b
      ub4 kxidsqn                           @72       0x0000078f
   struct ktbituba, 8 bytes                 @76
      ub4 kubadba                           @76       0x00c00754
      ub2 kubaseq                           @80       0x03cc
      ub1 kubarec                           @82       0x03
   ub2 ktbitflg                             @84       0x8000 (KTBFCOM)
   union _ktbitun, 2 bytes                  @86
      sb2 _ktbitfsc                         @86       3
      ub2 _ktbitwrp                         @86       0x0003
   ub4 ktbitbas                             @88       0x17726fba
--//这个时候才修改该事务槽.

4.继续:
SCOTT@book> update t set id=id where id<=500;
500 rows updated.

SCOTT@book> commit ;
Commit complete.

SCOTT@book> alter system flush buffer_cache;
System altered.

--//bbed观察:
BBED> p  dba 4,3499  ktbbh.ktbbhitl[2]
struct ktbbhitl[2], 24 bytes                @92
   struct ktbitxid, 8 bytes                 @92
      ub2 kxidusn                           @92       0x000a
      ub2 kxidslt                           @94       0x000f
      ub4 kxidsqn                           @96       0x00005140
   struct ktbituba, 8 bytes                 @100
      ub4 kubadba                           @100      0x00c001bb
      ub2 kubaseq                           @104      0x10d2
      ub1 kubarec                           @106      0x07
   ub2 ktbitflg                             @108      0x21f4 (KTBFUPB)
~~~~~~~~~~~ --//我修改并提交,而且提交时该块还在数据缓存,这样快速提交,修改ktbitflg=0x21f4.(0x1f4= 500)
   union _ktbitun, 2 bytes                  @110
      sb2 _ktbitfsc                         @110      0
      ub2 _ktbitwrp                         @110      0x0000
   ub4 ktbitbas                             @112      0x1772772f

SYS@book> alter system dump datafile 4 block 3499;
System altered.

--//转储信息:
Block header dump:  0x01000dab
 Object id on Block? Y
 seg/obj: 0x16223  csc: 0x03.177275d8  itc: 3  flg: E  typ: 1 - DATA
     brn: 0  bdba: 0x1000da8 ver: 0x01 opc: 0
     inc: 0  exflg: 0

 Itl           Xid                  Uba         Flag  Lck        Scn/Fsc
0x01   0xffff.000.00000000  0x00000000.0000.00  C---    0  scn 0x0003.177274e5
0x02   0x000a.016.00005143  0x00c001b8.10d2.06  C---    0  scn 0x0003.177275ce
0x03   0x000a.00f.00005140  0x00c001bb.10d2.07  --U-  500  fsc 0x0000.1772772f
bdba: 0x01000dab
data_block_dump,data header at 0x7f08e9727a7c
--//使用U表示 flag,对应就是0x2.很明显0x8表示提交.

5.现在通过bbed修改观察ktbitflg的情况.

BBED> assign dba 4,3499  ktbbh.ktbbhitl[2].ktbitflg=0x11f4;
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
ub2 ktbitflg                                @108      0x11f4 (KTBFTAC)

BBED> p dba 4,3499  ktbbh.ktbbhitl[2].ktbitflg
ub2 ktbitflg                                @108      0x11f4 (KTBFTAC)

BBED> sum apply dba 4,3499
Check value for File 4, Block 3499:
current = 0xd412, required = 0xd412

SYS@book> alter system dump datafile 4 block 3499;
System altered.

--//转储信息:
Block header dump:  0x01000dab
 Object id on Block? Y
 seg/obj: 0x16223  csc: 0x03.177275d8  itc: 3  flg: E  typ: 1 - DATA
     brn: 0  bdba: 0x1000da8 ver: 0x01 opc: 0
     inc: 0  exflg: 0

 Itl           Xid                  Uba         Flag  Lck        Scn/Fsc
0x01   0xffff.000.00000000  0x00000000.0000.00  C---    0  scn 0x0003.177274e5
0x02   0x000a.016.00005143  0x00c001b8.10d2.06  C---    0  scn 0x0003.177275ce
0x03   0x000a.00f.00005140  0x00c001bb.10d2.07  ---T  500  fsc 0x0000.1772772f
bdba: 0x01000dab
data_block_dump,data header at 0x7f08e9727a7c

--//T 表示0x1,好像没人看见过这样的标识.

BBED> assign dba 4,3499  ktbbh.ktbbhitl[2].ktbitflg=0x41f4;
ub2 ktbitflg                                @108      0x41f4 (KTBFIBI)

BBED> sum apply dba 4,3499
Check value for File 4, Block 3499:
current = 0x8412, required = 0x8412

SYS@book> alter system dump datafile 4 block 3499;
System altered.

--//转储信息:
Block header dump:  0x01000dab
 Object id on Block? Y
 seg/obj: 0x16223  csc: 0x03.177275d8  itc: 3  flg: E  typ: 1 - DATA
     brn: 0  bdba: 0x1000da8 ver: 0x01 opc: 0
     inc: 0  exflg: 0

 Itl           Xid                  Uba         Flag  Lck        Scn/Fsc
0x01   0xffff.000.00000000  0x00000000.0000.00  C---    0  scn 0x0003.177274e5
0x02   0x000a.016.00005143  0x00c001b8.10d2.06  C---    0  scn 0x0003.177275ce
0x03   0x000a.00f.00005140  0x00c001bb.10d2.07  -B--  500  fsc 0x0000.1772772f
bdba: 0x01000dab
data_block_dump,data header at 0x7f08e9727a7c
--//B 表示0x4,好像也没人看见过这样的标识.

BBED> assign dba 4,3499  ktbbh.ktbbhitl[2].ktbitflg=0xf1f4;
ub2 ktbitflg                                @108      0xf1f4 (KTBFTAC, KTBFUPB, KTBFIBI, KTBFCOM)

BBED> sum apply dba 4,3499
Check value for File 4, Block 3499:
current = 0x3412, required = 0x3412

BBED> p dba 4,3499  ktbbh.ktbbhitl[2].ktbitflg
ub2 ktbitflg                                @108      0xf1f4 (KTBFTAC, KTBFUPB, KTBFIBI, KTBFCOM)

SYS@book> alter system dump datafile 4 block 3499;
System altered.

--//转储信息:
Block header dump:  0x01000dab
 Object id on Block? Y
 seg/obj: 0x16223  csc: 0x03.177275d8  itc: 3  flg: E  typ: 1 - DATA
     brn: 0  bdba: 0x1000da8 ver: 0x01 opc: 0
     inc: 0  exflg: 0

 Itl           Xid                  Uba         Flag  Lck        Scn/Fsc
0x01   0xffff.000.00000000  0x00000000.0000.00  C---    0  scn 0x0003.177274e5
0x02   0x000a.016.00005143  0x00c001b8.10d2.06  C---    0  scn 0x0003.177275ce
0x03   0x000a.00f.00005140  0x00c001bb.10d2.07  CBUT    0  scn 0x0000.1772772f
bdba: 0x01000dab
data_block_dump,data header at 0x7f08e9727a7c

--//KTBFTAC, KTBFUPB, KTBFIBI, KTBFCOM 分别标识 0x1,0x2,0x4,0x8.
--//比较常见的组合前4位是0x8,0x2,0xa,0x0
--//收尾还原.
BBED> assign dba 4,3499  ktbbh.ktbbhitl[2].ktbitflg=0x21f4;
ub2 ktbitflg                                @108      0x21f4 (KTBFUPB)

BBED> sum apply dba 4,3499
Check value for File 4, Block 3499:
current = 0xe412, required = 0xe412

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


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/267265/viewspace-2758736/,如需转载,请注明出处,否则将追究法律责任。

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

注册时间:2008-01-03

  • 博文量
    2855
  • 访问量
    6643915