[20181222]如何找出回滾操作.txt
[20181222]如何找出回滾操作.txt
--//連結問的問題,http://www.itpub.net/thread-2107324-1-1.html.
--//每秒有422.7個rollback.如果找到發生回滾的操作.
--//首先一點應該更佳關注transaction rollbacks。透過測試說明問題。
1.環境:
SCOTT@test01p> @ ver1
PORT_STRING VERSION BANNER CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0 12.2.0.1.0 Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production 0
2.測試一:
SCOTT@test01p> @ viewsess rollback
NAME STATISTIC# VALUE SID
---------------------------------------------- ---------- ---------- ----------
user rollbacks 7 0 89
transaction tables consistent read rollbacks 597 0 89
rollbacks only - consistent read gets 601 0 89
cleanouts and rollbacks - consistent read gets 602 0 89
rollback changes - undo records applied 607 0 89
transaction rollbacks 608 0 89
IMU CR rollbacks 656 0 89
IM populate undo segheader rollback 689 0 89
IM repopulate undo segheader rollback 697 0 89
IM scan CUs rollback 710 0 89
IM scan CUs no rollback 711 0 89
11 rows selected.
SCOTT@test01p> rollback;
Rollback complete.
SCOTT@test01p> @ viewsess rollback
NAME STATISTIC# VALUE SID
---------------------------------------------- ---------- ---------- ----------
user rollbacks 7 1 89
transaction tables consistent read rollbacks 597 0 89
rollbacks only - consistent read gets 601 0 89
cleanouts and rollbacks - consistent read gets 602 0 89
rollback changes - undo records applied 607 0 89
transaction rollbacks 608 0 89
IMU CR rollbacks 656 0 89
IM populate undo segheader rollback 689 0 89
IM repopulate undo segheader rollback 697 0 89
IM scan CUs rollback 710 0 89
IM scan CUs no rollback 711 0 89
11 rows selected.
--//所以不能關注user rollbacks,而應該更多的關注transaction rollbacks.
3.如何找到回滾操作,測試logminer看看。
SYSTEM@test> alter database add supplemental log data;
Database altered.
--//開啟附加日誌,不然logminer會漏掉一些語句,如果不開啟,我真不知道使用logminer是否可行。
SCOTT@test01p> create table t as select rownum id ,lpad('x',100,'x') name from dual connect by level<=2;
Table created.
--//建立指令碼:
$ cat undo_t.txt
column member new_value v_member
column member noprint
set numw 12
pause run alter system archive log current or alter system switch logfile;
--//12c不允許在pluggable database執行這條命令
--//alter system archive log current;
SELECT member FROM v$log a, v$logfile b WHERE a.group#(+) = b.group# and a.STATUS='CURRENT' and rownum=1;
column curr1 new_value v_curr1
select current_scn curr1 from v$database;
--//以下操作內容:
update t set name=lpad('y',100,'y') where id=1;
commit ;
update t set name=lpad('z',100,'z') where id=2;
rollback ;
column curr2 new_value v_curr2
select current_scn curr2 from v$database;
prompt exec DBMS_LOGMNR.START_LOGMNR(STARTSCN => &&v_curr1 ,ENDSCN => &&v_curr2 ,OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + DBMS_LOGMNR.CONTINUOUS_MINE);
prompt alter system dump logfile '&&v_member' scn min &&v_curr1 scn max &&v_curr2;
alter system dump logfile '&&v_member' scn min &&v_curr1 scn max &&v_curr2;
@pp
SCOTT@test01p> @ undo_t.txt
run alter system archive log current or alter system switch logfile
CURR1
------------
5870518
1 row updated.
Commit complete.
1 row updated.
Rollback complete.
CURR2
------------
5870530
exec DBMS_LOGMNR.START_LOGMNR(STARTSCN => 5870518 ,ENDSCN => 5870530 ,OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + DBMS_LOGMNR.CONTINUOUS_MINE)
alter system dump logfile 'D:\APP\ORACLE\ORADATA\TEST\REDO02.LOG' scn min 5870518 scn max 5870530
old 1: alter system dump logfile '&&v_member' scn min &&v_curr1 scn max &&v_curr2
new 1: alter system dump logfile 'D:\APP\ORACLE\ORADATA\TEST\REDO02.LOG' scn min 5870518 scn max 5870530
System altered.
TRACEFILE
--------------------------------------------------------------------------------
D:\APP\ORACLE\PRODUCT\12.2.0\DBHOME_1\RDBMS\TRACE\test_ora_4600.trc
4.使用logminer分析:
--//登入cdb,執行如下:
SYSTEM@test> BEGIN
2 DBMS_LOGMNR.START_LOGMNR
3 (
4 STARTSCN => 5870518
5 ,ENDSCN => 5870530
6 ,OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG
7 + DBMS_LOGMNR.CONTINUOUS_MINE
8 );
9 END;
10 /
PL/SQL procedure successfully completed.
SYSTEM@test> create table x1 as select * from V$LOGMNR_CONTENTS;
Table created.
SYSTEM@test> EXECUTE DBMS_LOGMNR.END_LOGMNR;
PL/SQL procedure successfully completed.
SYSTEM@test> BEGIN
2 DBMS_LOGMNR.START_LOGMNR
3 (
4 STARTSCN => 5870518
5 ,ENDSCN => 5870530
6 ,OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG
7 + DBMS_LOGMNR.COMMITTED_DATA_ONLY
8 + DBMS_LOGMNR.CONTINUOUS_MINE
9 );
10 END;
11 /
PL/SQL procedure successfully completed.
SYSTEM@test> create table x2 as select * from V$LOGMNR_CONTENTS;
Table created.
SYSTEM@test> EXECUTE DBMS_LOGMNR.END_LOGMNR;
PL/SQL procedure successfully completed.
SYSTEM@test> column sql_redo format a60
SYSTEM@test> select scn,rs_id,sql_redo from system.x1
2 minus
3 select scn,rs_id,sql_redo from system.x2
4 /
SCN RS_ID SQL_REDO
---------- -------------------------------- ------------------------------------------------------------
5870524 0x00005f.00004a11.0010 set transaction read write;
5870524 0x00005f.00004a11.0010 update "SCOTT"."T" set "NAME" = 'zzzzzzzzzzzzzzzzzzzzzzzzzzz
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
zzzzzzzzzzzzz' where "NAME" = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxx' and ROWID = 'AAAF5JAALAAAACrAAB';
5870525 0x00005f.00004a12.00f8
5870527 0x00005f.00004a13.0010 update "SCOTT"."T" set "NAME" = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxx' where ROWID = 'AAAF5JAALAAAACrAAB';
5870528 0x00005f.00004a13.016c rollback;
--//注不能使用select * from system.x1 minus select * from system.x2,因為沒有引數DBMS_LOGMNR.COMMITTED_DATA_ONLY
--//的情況下,start_scn,stop_scn在檢視 V$LOGMNR_CONTENTS為空。
--//你可以發現整個回滾的整個操作。理論將如果存在這個高的回滾事務,應該看出問題在哪裡。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2286139/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 回滾操作、回滾段的理解
- sqlserver遇到回滾事務的操作策略SQLServer
- github如何回滾單個檔案Github
- oracle前滾和回滾Oracle
- ORACLE 前滾和回滾Oracle
- [20150715]10513事件禁止smon回滾.txt事件
- oracle回滾溯源Oracle
- ORACLE回滾段Oracle
- IDEA程式碼不想提交了,如何回滾Idea
- 客戶端登陸logout操作,事務回滾客戶端Go
- 詳解command設計模式,解耦操作和回滾設計模式解耦
- Oracle 資料回滾Oracle
- Mac回滾iTunes版本Mac
- MONGODB 回滾失敗MongoDB
- ORACLE回滾段(1)Oracle
- ORACLE回滾段(2)Oracle
- ORACLE回滾段(轉)Oracle
- ORACLE回滾段管理Oracle
- 在 RHEL/CentOS 系統上使用 YUM history 命令回滾升級操作CentOS
- SQL code----檢視回滾段名稱及大小 回滾段的管理SQL
- Spring Boot 事物回滾Spring Boot
- java 事務提交/回滾Java
- ORACLE 回滾段詳解Oracle
- 入門Kubernetes - 滾動升級/回滾
- 關於前滾(roll forward)和回滾(roll back)Forward
- 鎖表時KILL SESSION及回滾段監控(回滾時間評估)Session
- Pycharm 如何檢視程式碼修改歷史|回滾程式碼PyCharm
- Oracle例項恢復——說說前滾和回滾Oracle
- 談談 Git 程式碼回滾Git
- Git回滾程式碼暴力法Git
- Oracle提交和回滾處理Oracle
- Oracle的回滾段介紹Oracle
- ORACLE 死事務的回滾Oracle
- 使用 Flash Table 回滾資料
- Oracle vs PostgreSQL,研發注意事項(3)- 事務回滾之UPDATE操作解析OracleSQL
- 回滾莫隊學習筆記筆記
- Spring的事物回滾問題Spring
- Spring事務回滾情況Spring