回滾段頭重要的數據結構Control SCN
2024-07-21 02:33:19
供稿:網友
在回滾段頭有一個重要的數據結構稱為:Control SCN.
這個SCN是最近一個被重用的事務槽的SCN(重用是按事務的先后順序重用的)。假如Control SCN比查詢的Snapshot SCN新,那么Oracle不會試圖去構造前鏡像,而是馬上返回ORA-01555錯誤,因為這個UNDO信息肯定已經被覆蓋了。
這個Control SCN也會被用于delayed logging cleanout的提交SCN(僅當歷史事務的UNDO信息已經被覆蓋),在ITL中這個SCN被標記為U,代表"upper bound commit".
我們來看一下這個數據結構:
SQL> create table ud ( n number );
Table created
SQL> insert into ud values(1);
1 row inserted
SQL> insert into ud values(2);
1 row inserted
SQL> commit;
Commit complete
SQL>
SQL> select * from ud;
N
----------
1
2
SQL> update ud set n=1000 where n=2;
1 row updated
SQL> select * from ud;
N
----------
1
1000
SQL> select xidusn,xidslot,xidsqn,ubablk,ubafil,ubarec from v$transaction;
XIDUSN XIDSLOT XIDSQN UBABLK UBAFIL UBAREC
---------- ---------- ---------- ---------- ---------- ----------
2 30 11407 251 2 10
SQL> select usn,name from v$rollname where usn=2;
USN NAME
---------- ------------------------------
2 _SYSSMU2$
SQL> alter system dump undo header '_SYSSMU2$';
System altered
檢查trace文件(摘錄):
TRN CTL:: seq: 0x02cd chd: 0x002e ctl: 0x0018 inc: 0x00000000 nfb: 0x0000
mgc: 0x8201 xts: 0x0068 flg: 0x0001 opt: 2147483646 (0x7ffffffe)
uba: 0x008000fb.02cd.0a scn: 0x0000.0e21169a
這里TRN CTL部分的scn就是前面我們所說的Contrl SCN.