oracle實驗記錄 (dump undo4)

fufuh2o發表於2009-06-26

連線到:
Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> select * from test;

TESTCOL
--------------------
de
de

SQL> select dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_nu
mber(rowid) blk# from test;

     FILE#       BLK#
---------- ----------
         1      56802
         1      56802

SQL> update test set testcol='z';

已更新2行。

SQL> commit
  2  ;

提交完成。

SQL> alter system dump datafile 1 block 56802;

系統已更改。

SQL> update test set testcol='zz';

已更新2行。

SQL> commit
  2  ;

提交完成。

SQL> alter system dump datafile 1 block 56802;

系統已更改。

SQL> update test set testcol='zzzz';

已更新2行。

SQL> commit
  2  ;

提交完成。

SQL> alter system dump datafile 1 block 56802;

系統已更改。

SQL> update test set testcol='zzzz';

已更新2行。

SQL> alter system dump datafile 1 block 56802;

系統已更改。     

SQL>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~dump出來的

*** 2008-11-07 11:04:06.921
*** SERVICE NAME:(SYS$USERS) 2008-11-07 11:04:06.906
*** SESSION ID:(154.29) 2008-11-07 11:04:06.906
Start dump data blocks tsn: 0 file#: 1 minblk 56802 maxblk 56802
buffer tsn: 0 rdba: 0x0040dde2 (1/56802)
scn: 0x0000.0042ef7d seq: 0x01 flg: 0x02 tail: 0xef7d0601
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Block header dump:  0x0040dde2
 Object id on Block? Y
 seg/obj: 0xd1fb  csc: 0x00.428554  itc: 2  flg: O  typ: 1 - DATA
     fsl: 0  fnx: 0x0 ver: 0x01
 
 Itl           Xid                  Uba         Flag  Lck        Scn/Fsc
0x01   0x0006.023.000002c3  0x008002ff.01b6.20  C---    0  scn 0x0000.00428550
0x02   0x0001.02f.000007c2  0x008011b6.02db.12  --U-    2  fsc 0x0000.0042ef7d~~~~~~~~~~~~~~~~~~~已經commit 第一次更新Z時候 舊值得UBA裡值de;
 
data_block_dump,data header at 0x61c025c
===============
tsiz: 0x1fa0
hsiz: 0x1a
pbl: 0x061c025c
bdba: 0x0040dde2
     76543210
flag=--------
ntab=1
nrow=4
frre=0
fsbo=0x1a
fseo=0x1e8a
avsp=0x1f74
tosp=0x1f74
0xe:pti[0] nrow=4 offs=0
0x12:pri[0] sfll=1
0x14:pri[1] sfll=-1
0x16:pri[2] offs=0x1e8f
0x18:pri[3] offs=0x1e8a
block_row_dump:
tab 0, row 2, @0x1e8f
tl: 5 fb: --H-FL-- lb: 0x2  cc: 1
col  0: [ 1]  7a~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~第一次更新Z
tab 0, row 3, @0x1e8a
tl: 5 fb: --H-FL-- lb: 0x2  cc: 1
col  0: [ 1]  7a~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~第一次更新Z
end_of_block_dump
End dump data blocks tsn: 0 file#: 1 minblk 56802 maxblk 56802
*** 2008-11-07 11:04:21.562
Start dump data blocks tsn: 0 file#: 1 minblk 56802 maxblk 56802
buffer tsn: 0 rdba: 0x0040dde2 (1/56802)
scn: 0x0000.0042ef88 seq: 0x01 flg: 0x02 tail: 0xef880601
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Block header dump:  0x0040dde2
 Object id on Block? Y
 seg/obj: 0xd1fb  csc: 0x00.42ef85  itc: 2  flg: O  typ: 1 - DATA
     fsl: 0  fnx: 0x0 ver: 0x01
 
 Itl           Xid                  Uba         Flag  Lck        Scn/Fsc
0x01   0x0007.027.00000263  0x008008ef.02cd.19  --U-    2  fsc 0x0000.0042ef88~~~第2次更新~zz時候 這個位置的 ITL被換出去了 放入最新更新已提交 uba裡值Z 
0x02   0x0001.02f.000007c2  0x008011b6.02db.12  C---    0  scn 0x0000.0042ef7d~~~~~~~~~~~~~~~~~~~~~~~~~~~~原來更新Z時候的 已經變為C  uba裡值de
 
data_block_dump,data header at 0x61c025c
===============
tsiz: 0x1fa0
hsiz: 0x1a
pbl: 0x061c025c
bdba: 0x0040dde2
     76543210
flag=--------
ntab=1
nrow=4
frre=0
fsbo=0x1a
fseo=0x1e7e
avsp=0x1f74
tosp=0x1f74
0xe:pti[0] nrow=4 offs=0
0x12:pri[0] sfll=1
0x14:pri[1] sfll=-1
0x16:pri[2] offs=0x1e84
0x18:pri[3] offs=0x1e7e
block_row_dump:
tab 0, row 2, @0x1e84
tl: 6 fb: --H-FL-- lb: 0x1  cc: 1
col  0: [ 2]  7a 7a
tab 0, row 3, @0x1e7e
tl: 6 fb: --H-FL-- lb: 0x1  cc: 1
col  0: [ 2]  7a 7a
end_of_block_dump
End dump data blocks tsn: 0 file#: 1 minblk 56802 maxblk 56802
Start dump data blocks tsn: 0 file#: 1 minblk 56802 maxblk 56802
buffer tsn: 0 rdba: 0x0040dde2 (1/56802)
scn: 0x0000.0042ef8d seq: 0x01 flg: 0x02 tail: 0xef8d0601
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Block header dump:  0x0040dde2
 Object id on Block? Y
 seg/obj: 0xd1fb  csc: 0x00.42ef8b  itc: 2  flg: O  typ: 1 - DATA
     fsl: 0  fnx: 0x0 ver: 0x01
 
 Itl           Xid                  Uba         Flag  Lck        Scn/Fsc
0x01   0x0007.027.00000263  0x008008ef.02cd.19  C---    0  scn 0x0000.0042ef88~~~~~~~~~~~~~~~~~~~~~更新ZZ時候的 uba裡值Z
0x02   0x0003.016.00000bd8  0x0080075b.07fa.28  --U-    2  fsc 0x0000.0042ef8d~~~~~~~~第一次更新Z的已經被換出去變為第3次更新ZZZZ~ UBA裡值zz~~~並且已經commit
 
data_block_dump,data header at 0x61c025c
===============
tsiz: 0x1fa0
hsiz: 0x1a
pbl: 0x061c025c
bdba: 0x0040dde2
     76543210
flag=--------
ntab=1
nrow=4
frre=0
fsbo=0x1a
fseo=0x1e6e
avsp=0x1f74
tosp=0x1f74
0xe:pti[0] nrow=4 offs=0
0x12:pri[0] sfll=1
0x14:pri[1] sfll=-1
0x16:pri[2] offs=0x1e76
0x18:pri[3] offs=0x1e6e
block_row_dump:
tab 0, row 2, @0x1e76
tl: 8 fb: --H-FL-- lb: 0x2  cc: 1
col  0: [ 4]  7a 7a 7a 7a~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~zzzzz
tab 0, row 3, @0x1e6e
tl: 8 fb: --H-FL-- lb: 0x2  cc: 1
col  0: [ 4]  7a 7a 7a 7a~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~zzzzz
end_of_block_dump
End dump data blocks tsn: 0 file#: 1 minblk 56802 maxblk 56802
Start dump data blocks tsn: 0 file#: 1 minblk 56802 maxblk 56802
buffer tsn: 0 rdba: 0x0040dde2 (1/56802)
scn: 0x0000.0042ef90 seq: 0x02 flg: 0x00 tail: 0xef900602
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Block header dump:  0x0040dde2
 Object id on Block? Y
 seg/obj: 0xd1fb  csc: 0x00.42ef90  itc: 2  flg: O  typ: 1 - DATA
     fsl: 0  fnx: 0x0 ver: 0x01
 
 Itl           Xid                  Uba         Flag  Lck        Scn/Fsc
0x01   0x0005.02b.000003c8  0x00800543.0213.20  ----    2  fsc 0x0000.00000000~~~~~~~~~~~~~~~~~~~~~~第4次更新還為ZZZZ但未提交,UBA裡值第一次ZZZZ的
0x02   0x0003.016.00000bd8  0x0080075b.07fa.28  C---    0  scn 0x0000.0042ef8d~~~~~~~~~~~~~~~~~~~~~~第一次ZZZZ的變為了C,UBA值ZZ
 
data_block_dump,data header at 0x61c025c
===============
tsiz: 0x1fa0
hsiz: 0x1a
pbl: 0x061c025c
bdba: 0x0040dde2
     76543210
flag=--------
ntab=1
nrow=4
frre=0
fsbo=0x1a
fseo=0x1e6e
avsp=0x1f74
tosp=0x1f74
0xe:pti[0] nrow=4 offs=0
0x12:pri[0] sfll=1
0x14:pri[1] sfll=-1
0x16:pri[2] offs=0x1e76
0x18:pri[3] offs=0x1e6e
block_row_dump:
tab 0, row 2, @0x1e76
tl: 8 fb: --H-FL-- lb: 0x1  cc: 1
col  0: [ 4]  7a 7a 7a 7a
tab 0, row 3, @0x1e6e
tl: 8 fb: --H-FL-- lb: 0x1  cc: 1
col  0: [ 4]  7a 7a 7a 7a
end_of_block_dump
End dump data blocks tsn: 0 file#: 1 minblk 56802 maxblk 56802

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~問題來了若一個長時間查詢~在還未更新Z時候開始~~當用到更新的這個塊的時候,塊中ITL 已經無以回滾段資訊了 如何構建CR塊

問題解決在於 在 undo中也存在 對ITL改變的記錄~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~先根據最新的 UBA 0x00800543.0213.20  去找 未COMMIT的

SQL> variable file# number
SQL> variable blk# number
SQL> execute :file#:=dbms_utility.data_block_address_file(to_number('800543','xx
xxxx'));

PL/SQL 過程已成功完成。

SQL> execute :blk#:=dbms_utility.data_block_address_block(to_number('800543','xx
xxxx'));

PL/SQL 過程已成功完成。

SQL> print file#;

     FILE#
----------
         2

SQL> print blk#;

      BLK#
----------
      1347

SQL>

SQL> alter system dump datafile 2 block  1347;

系統已更改。


*-----------------------------
* Rec #0x1f  slt: 0x2b  objn: 53755(0x0000d1fb)  objd: 53755  tblspc: 0(0x00000000)
*       Layer:  11 (Row)   opc: 1   rci 0x00  
Undo type:  Regular undo    Begin trans    Last buffer split:  No
Temp Object:  No
Tablespace Undo:  No
rdba: 0x00000000
*-----------------------------
uba: 0x00800543.0213.1d ctl max scn: 0x0000.0042e921 prv tx scn: 0x0000.0042e95b
txn start scn: scn: 0x0000.0042ef90 logon user: 0
 prev brb: 8389945 prev bcl: 0
KDO undo record:
KTB Redo
op: 0x04  ver: 0x01 
op: L  itl: xid:  0x0007.027.00000263 uba: 0x008008ef.02cd.19~~~~~~~~~~~~~~~~~~~~~~~~~~這條記錄著 更改ZZ時候的UBA~uba裡值Z~還包括ZZ ITL槽中資訊
                      flg: C---    lkc:  0     scn: 0x0000.0042ef88
KDO Op code: URP row dependencies Disabled
  xtype: XA flags: 0x00000000  bdba: 0x0040dde2  hdba: 0x0040dde1
itli: 1  ispac: 0  maxfr: 4863
tabn: 0 slot: 2(0x2) flag: 0x2c lock: 0 ckix: 6
ncol: 1 nnew: 1 size: 0
col  0: [ 4]  7a 7a 7a 7a~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~儲存上一條 更新的ZZZZ
 
*-----------------------------
* Rec #0x20  slt: 0x2b  objn: 53755(0x0000d1fb)  objd: 53755  tblspc: 0(0x00000000)
*       Layer:  11 (Row)   opc: 1   rci 0x1f  
Undo type:  Regular undo   Last buffer split:  No
Temp Object:  No
Tablespace Undo:  No
rdba: 0x00000000
*-----------------------------
KDO undo record:
KTB Redo
op: 0x02  ver: 0x01 
op: C  uba: 0x00800543.0213.1f
KDO Op code: URP row dependencies Disabled
  xtype: XA flags: 0x00000000  bdba: 0x0040dde2  hdba: 0x0040dde1
itli: 1  ispac: 0  maxfr: 4863
tabn: 0 slot: 3(0x3) flag: 0x2c lock: 0 ckix: 6
ncol: 1 nnew: 1 size: 0
col  0: [ 4]  7a 7a 7a 7a~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~儲存上一條 更新的ZZZZ
 
End dump data blocks tsn: 1 file#: 2 minblk 1347 maxblk 1347

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~等於替換這個塊ITL槽資訊的 UBA中記錄上一個ITL 記錄的資訊


~~~~~~~~~~~~~~~~來看看 

0x02   0x0003.016.00000bd8  0x0080075b.07fa.28  C---    0  scn 0x0000.0042ef8d~~~~~~~~~~~~~~~~~~~~~~第一次ZZZZ的變為了C 這個沒被換出去的ITL ,中uba 儲存什麼

 

SQL> execute :blk#:=dbms_utility.data_block_address_block(to_number('80075b','xx
xxxx'));

PL/SQL 過程已成功完成。

SQL> execute :file#:=dbms_utility.data_block_address_file(to_number('80075b','xx
xxxx'));

PL/SQL 過程已成功完成。

SQL> print file#

     FILE#
----------
         2

SQL> print blk#

      BLK#
----------
      1883


SQL> alter system dump datafile 2 block 1883;

系統已更改。

SQL>

 

 

* Rec #0x27  slt: 0x16  objn: 53755(0x0000d1fb)  objd: 53755  tblspc: 0(0x00000000)
*       Layer:  11 (Row)   opc: 1   rci 0x00  
Undo type:  Regular undo    Begin trans    Last buffer split:  No
Temp Object:  No
Tablespace Undo:  No
rdba: 0x00000000
*-----------------------------
uba: 0x0080075b.07fa.24 ctl max scn: 0x0000.0042e920 prv tx scn: 0x0000.0042e959
txn start scn: scn: 0x0000.0042ef8b logon user: 0
 prev brb: 8390488 prev bcl: 0
KDO undo record:
KTB Redo
op: 0x04  ver: 0x01 
op: L  itl: xid:  0x0001.02f.000007c2 uba: 0x008011b6.02db.12~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~儲存第一個更新時候ITL ,Z的 uba
                      flg: C---    lkc:  0     scn: 0x0000.0042ef7d
KDO Op code: URP row dependencies Disabled
  xtype: XA flags: 0x00000000  bdba: 0x0040dde2  hdba: 0x0040dde1
itli: 2  ispac: 0  maxfr: 4863
tabn: 0 slot: 2(0x2) flag: 0x2c lock: 0 ckix: 6
ncol: 1 nnew: 1 size: -2
col  0: [ 2]  7a 7a~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~儲存ZZ
 
*-----------------------------
* Rec #0x28  slt: 0x16  objn: 53755(0x0000d1fb)  objd: 53755  tblspc: 0(0x00000000)
*       Layer:  11 (Row)   opc: 1   rci 0x27  
Undo type:  Regular undo   Last buffer split:  No
Temp Object:  No
Tablespace Undo:  No
rdba: 0x00000000
*-----------------------------
KDO undo record:
KTB Redo
op: 0x02  ver: 0x01 
op: C  uba: 0x0080075b.07fa.27
KDO Op code: URP row dependencies Disabled
  xtype: XA flags: 0x00000000  bdba: 0x0040dde2  hdba: 0x0040dde1
itli: 2  ispac: 0  maxfr: 4863
tabn: 0 slot: 3(0x3) flag: 0x2c lock: 0 ckix: 6
ncol: 1 nnew: 1 size: -2
col  0: [ 2]  7a 7a~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~儲存ZZ~~~~的

 


~~~假如有一個長時間查詢是 更新塊之前 開始的(未更新Z時候)查到這個塊時候~根據 uba找到UNDO BLK 根據裡面資訊構造CR塊~~~一點點 回滾直到滾到查詢SCN大於找到塊的SCN


先找到

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

相關文章