• oracle core04_undo


    undo信息

    oracle中undo的信息主要完成下面的功能:

    • 1,构建块一致性读
    • 2,回滚事务

    UBA:undo block address

    1,块中的事务槽ITL中的UBA表示这个ITL所在的block历经的最后一次改变所对应的undo record所在的UBA,主要用于一致读。

    2,undo segment header中的UBA表示所对应的transaction的undo chain的最后一个UBA,用于transaction的回滚。

    可以通过v$KTUXE视图来查看undo segment header中的transaction table情况。

    下面通过实验来看一下:

    1,查看undo segment header。

    第一步:更新记录

    SYS/SYS@ORCL>update test set name='jkkkkkkkkkkkkkkkkkkkkkk' where id=2;
    1 row updated.
    

    第二步:查看本事务使用的undo segment以及文件和块的情况

    SYS/SYS@ORCL>select XIDUSN as segment_id, ubafil as file_id, ubablk, start_ubablk, used_ublk from v$transaction;
    
    SEGMENT_ID    FILE_ID     UBABLK START_UBABLK  USED_UBLK
    ---------- ---------- ---------- ------------ ----------
            10          2        715          715          1
    
    1 row selected.
    SYS/SYS@ORCL>select segment_name, segment_id, file_id,block_id from dba_rollback_segs where segment_id=10;
    
    SEGMENT_NAME                                                 SEGMENT_ID    FILE_ID   BLOCK_ID
    ------------------------------------------------------------ ---------- ---------- ----------
    _SYSSMU10$                                                           10          2        153
    1 row selected.
    

    所以,本事务使用的undo segment_id为10,file_id为2,undo segment header的block_id为153。 下面dump这个undo segment header来看下:

      Extent Header:: spare1: 0      spare2: 0      #extents: 3      #blocks: 143   
                      last map  0x00000000  #maps: 0      offset: 4080  
          Highwater::  0x008002cd  ext#: 2      blk#: 68     ext size: 128   
      #blocks in seg. hdr's freelists: 0     
      #blocks below: 0     
      mapblk  0x00000000  offset: 2     
                       Unlocked
         Map Header:: next  0x00000000  #extents: 3    obj#: 0      flag: 0x40000000
      Extent Map
      -----------------------------------------------------------------
       0x0080009a  length: 7     
       0x008000d9  length: 8     
       0x00800289  length: 128   
      
     Retention Table 
      -----------------------------------------------------------
     Extent Number:0  Commit Time: 1326479408
     Extent Number:1  Commit Time: 1326479408
     Extent Number:2  Commit Time: 1326479408
      
      TRN CTL:: seq: 0x00f4 chd: 0x0021 ctl: 0x002b inc: 0x00000000 nfb: 0x0002
                mgc: 0x8201 xts: 0x0068 flg: 0x0001 opt: 2147483646 (0x7ffffffe)
                uba: 0x008002cb.00f4.0c scn: 0x0000.000ddd2f
    Version: 0x01
      FREE BLOCK POOL::
        uba: 0x00000000.00f4.0b ext: 0x2  spc: 0x1a64  
        uba: 0x008002cc.00f4.11 ext: 0x2  spc: 0xf9c   
        uba: 0x008002cd.00f4.01 ext: 0x2  spc: 0x1f88  
        uba: 0x00000000.00eb.01 ext: 0x2  spc: 0x1f88  
        uba: 0x00000000.00eb.01 ext: 0x2  spc: 0x1f88  
      TRN TBL::
     
      index  state cflags  wrap#    uel         scn            dba            parent-xid    nub     stmt_num    cmt
      ------------------------------------------------------------------------------------------------
       0x00    9    0x00  0x00f9  0x0011  0x0000.000e3357  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326654543
       0x01    9    0x00  0x00f9  0x0000  0x0000.000e3297  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326654005
       0x02    9    0x00  0x00f9  0x0006  0x0000.000e2fe0  0x008002bd  0x0000.000.00000000  0x00000001   0x00000000  1326652743
       0x03    9    0x00  0x00f9  0x0008  0x0000.000e3153  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326653343
       0x04    9    0x00  0x00f9  0x002d  0x0000.000e30f3  0x008002bd  0x0000.000.00000000  0x00000001   0x00000000  1326653343
       0x05    9    0x00  0x00f9  0x000c  0x0000.000e312a  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326653343
       0x06    9    0x00  0x00f9  0x0025  0x0000.000e30be  0x008002bd  0x0000.000.00000000  0x00000001   0x00000000  1326653343
       0x07    9    0x00  0x00f9  0x0015  0x0000.000e3188  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326653343
       0x08    9    0x00  0x00f9  0x000d  0x0000.000e315e  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326653343
       0x09    9    0x00  0x00f9  0x002e  0x0000.000e3115  0x008002bd  0x0000.000.00000000  0x00000001   0x00000000  1326653343
       0x0a    9    0x00  0x00f9  0x000e  0x0000.000e3173  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326653343
       0x0b    9    0x00  0x00f9  0x0009  0x0000.000e3108  0x008002bd  0x0000.000.00000000  0x00000001   0x00000000  1326653343
       0x0c    9    0x00  0x00f9  0x0028  0x0000.000e3134  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326653343
       0x0d    9    0x00  0x00f9  0x000a  0x0000.000e3168  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326653343
       0x0e    9    0x00  0x00f9  0x0007  0x0000.000e317e  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326653343
       0x0f    9    0x00  0x00f9  0x0010  0x0000.000e3376  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326654543
       0x10    9    0x00  0x00f9  0x0014  0x0000.000e3381  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326654543
       0x11    9    0x00  0x00f9  0x000f  0x0000.000e3364  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326654543
       0x12    9    0x00  0x00f9  0x001c  0x0000.000e37f2  0x008002cb  0x0000.000.00000000  0x00000001   0x00000000  1326657606
       0x13    9    0x00  0x00f8  0x001a  0x0000.000ddd4a  0x008002bd  0x0000.000.00000000  0x00000001   0x00000000  1326492007
       0x14    9    0x00  0x00f9  0x0016  0x0000.000e34ee  0x008002bf  0x0000.000.00000000  0x00000001   0x00000000  1326655603
       0x15    9    0x00  0x00f9  0x0001  0x0000.000e3286  0x008002be  0x0000.000.00000000  0x00000001   0x00000000  1326654003
       0x16    9    0x00  0x00f9  0x001b  0x0000.000e352d  0x008002bf  0x0000.000.00000000  0x00000001   0x00000000  1326655743
       0x17    9    0x00  0x00f9  0x0018  0x0000.000e3568  0x008002cb  0x0000.000.00000000  0x00000001   0x00000000  1326655803
       0x18    9    0x00  0x00f9  0x0012  0x0000.000e375b  0x008002cb  0x0000.000.00000000  0x00000001   0x00000000  1326657242
       0x19    9    0x00  0x00f9  0x0026  0x0000.000e3554  0x008002c8  0x0000.000.00000000  0x00000003   0x00000000  1326655802
       0x1a    9    0x00  0x00f8  0x001d  0x0000.000ddeb0  0x008002bd  0x0000.000.00000000  0x00000001   0x00000000  1326493035
       0x1b    9    0x00  0x00f9  0x0019  0x0000.000e3553  0x008002c3  0x0000.000.00000000  0x00000003   0x00000000  1326655802
       0x1c    9    0x00  0x00f9  0x002b  0x0000.000e874a  0x008002cb  0x0000.000.00000000  0x00000001   0x00000000  1326657871
       0x1d    9    0x00  0x00f8  0x002a  0x0000.000e2e6d  0x008002bd  0x0000.000.00000000  0x00000001   0x00000000  1326652128
       0x1e    9    0x00  0x00f8  0x0027  0x0000.000ddd32  0x008002bd  0x0000.000.00000000  0x00000003   0x00000000  1326492003
       0x1f    9    0x00  0x00f8  0x0017  0x0000.000e3556  0x008002cc  0x0000.000.00000000  0x00000007   0x00000000  1326655802
       0x20    9    0x00  0x00f8  0x001e  0x0000.000ddd31  0x008002ba  0x0000.000.00000000  0x00000003   0x00000000  1326492003
       0x21    9    0x00  0x00f8  0x0020  0x0000.000ddd30  0x008002b8  0x0000.000.00000000  0x00000003   0x00000000  1326492003
       0x22    9    0x00  0x00f8  0x0002  0x0000.000e2f0d  0x008002bd  0x0000.000.00000000  0x00000001   0x00000000  1326652202
       

    0x23 10 0x80 0x00f9 0x0002 0x0000.000e8781 0x008002cb 0x0000.000.00000000 0x00000001 0x00000000 0然后dump 数据块看一下itl的情况

       Itl           Xid                  Uba         Flag  Lck        Scn/Fsc
    0x01   0x0008.029.0000012a  0x0080036a.00f3.05  C---    0  scn 0x0000.000d6ead
    0x02   0x000a.023.000000f9  0x008002cb.00f4.0c  ----    1  fsc 0x0000.00000000
    0x03   0x0005.00f.00000148  0x0080004c.019f.16  C---    0  scn 0x0000.000d6ea7
    

    下面再dump undo 块的内容看一下:

    UNDO BLK:  
    xid: 0x000a.023.000000f9  seq: 0xf4  cnt: 0xc   irb: 0xc   icl: 0x0   flg: 0x0000
     
     Rec Offset      Rec Offset      Rec Offset      Rec Offset      Rec Offset
    ---------------------------------------------------------------------------
    0x01 0x1f70     0x02 0x1f1c     0x03 0x1e74     0x04 0x1e08     0x05 0x1d84     
    0x06 0x1d24     0x07 0x1cc4     0x08 0x1bd0     0x09 0x1b4c     0x0a 0x1aec     
    0x0b 0x1a8c     

    0x0c 0x19ec在itl中: xid中0x000a.023.000000f9, XID由三部分内容组成:XIDUSN(回滚段号),XIDSLOT(回滚段槽 号),XIDSQN(序列号) 0x000a代表undo segment id,即十进制为10。023代表undo segment header中的回滚槽,即transaction table中的一行。 000000f9代表序列号。XID对应一个UBA(undo block address),表示该事务回滚信息的开始位置, 这个通过v$transaction可以对应上:

    SYS/SYS@ORCL>select xidusn,xidslot,xidsqn,ubafil,ubablk,ubasqn,ubarec from
      2     v$transaction;
    
        XIDUSN    XIDSLOT     XIDSQN     UBAFIL     UBABLK     UBASQN     UBAREC
    ---------- ---------- ---------- ---------- ---------- ---------- ----------
            10         35        249          2        715        244         12
    
    1 row selected.
    

    XIDUSN,XIDSLOT,XIDSQN共同组成了Xid。UBAFIL,UBABLK,UBASQN,UBAREC共同组成了undo segment header中transaction table中的UBA. 在每个data block的ITL中也有一个UBA,实际上这个UBA是指向了该block对应的undo信息的起始位置,这个UBA主要的作用是提供一致性读, 因为一 致性读需要通过undo信息来构造一个CR block,通过这个UBA就可以直接定位到block的回滚信息的起始位置,而不再需要通过undo segment header中的事务表。

  • 相关阅读:
    softice 在winice中的安装 zt
    普通版和优秀版简历的20项对比
    今天又投了几家。。等啊。。。
    乱写
    反攻击技术综合分析报告
    今天投简历的公司
    #pragma 预处理指令详解
    黑客入侵无线网络常用手段
    ADODB.Stream漏洞
    利用TCP/IP的堆栈指纹的方法
  • 原文地址:https://www.cnblogs.com/xpchild/p/3695136.html
Copyright © 2020-2023  润新知