[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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20140516]取出回滾段資訊.txt
- sqlserver遇到回滾事務的操作策略SQLServer
- 客戶端登陸logout操作,事務回滾客戶端Go
- 詳解command設計模式,解耦操作和回滾設計模式解耦
- IDEA程式碼不想提交了,如何回滾Idea
- oracle回滾溯源Oracle
- 入門Kubernetes - 滾動升級/回滾
- Kubernetes:更新與回滾
- Spring Boot 事物回滾Spring Boot
- Oracle 資料回滾Oracle
- 回滾與撤銷(一)
- Kubernetes:Pod 升級、回滾
- 深入UNDO回滾段,檢視爭用以及回滾段使用量的估算
- Pycharm 如何檢視程式碼修改歷史|回滾程式碼PyCharm
- [20210929]帶有回車的檔案如何改名.txt
- Oracle vs PostgreSQL,研發注意事項(3)- 事務回滾之UPDATE操作解析OracleSQL
- 談談 Git 程式碼回滾Git
- Spring的事物回滾問題Spring
- MySQL如何通過分析binlog日誌找出操作頻繁的表MySql
- 回滾莫隊學習筆記筆記
- [20191202]tmux共享回話.txtUX
- selenium+python 操作滾動條Python
- 實踐資料回滾解決方案
- spring boot 顯示處理事務回滾Spring Boot
- Git回滾程式碼到某個commitGitMIT
- git遠端分支回滾到指定版本Git
- 關於事務回滾註解@Transactional
- 【UNDO】Oracle系統回滾段說明Oracle
- 如何找出被鎖定的行
- ansible高階操作 serial滾動更新
- 「MacOS滑鼠操作技巧」如何設定滑鼠”的速度、滾動方向等配置?Mac
- BZOJ4241: 歷史研究(回滾莫隊)
- Spring Data JPA中事務回滾意外RollbackExceptionSpringException
- 利用oracle的日誌挖掘實現回滾Oracle
- MySQL死鎖案例一(回滾導致死鎖)MySql
- 拉鍊表的建立、查詢和回滾
- Oracle查詢回滾大事務所需時間Oracle
- 淺入Kubernetes(12):Deployment 的升級、回滾