oracle可以使用提交完成的事务,【体系结构】Oracle数据提交与事务隔离实验 oradebug挂起lgwr进程...
Oracle數據提交與事務隔離實驗
oradebug掛起lgwr進程
原文作者:dbsnake?崔華
實驗參考原文鏈接:
Oracle 里未 commit 的數據除了當前 session 之外,其他 session 是看不到的。
Oracle里未成功 commit 的數據我們也可能能看到。
同時啟4個 session:
session 1: 創(chuàng)建測試表test,插入一條數據但不提交
SCOTT@PROD>create table test (id number,name varchar2(20));
SCOTT@PROD>insert into test values (1,'lvxinghao');
SCOTT@PROD>select * from test;
session 2:查看test表,由于session 1未commit,session 2查看不到這條數據
SCOTT@PROD>select * from test;
SCOTT@PROD>select count(*) from test;
session 3:sys用戶查看并把lgwr進程suspend住(掛起):
操作系統(tǒng)查看LGWR進程號
[oracle@rhel64 ~]$ ps -ef | grep lgwr | grep -v grep
sys用戶查看lgwr后臺進程對應操作系統(tǒng)pid:
SYS@PROD>select spid from v$process where pname='LGWR';
掛起lgwr進程
SYS@PROD>oradebug setospid 5528
SYS@PROD>oradebug suspend
alert日志中信息顯示
[oracle@rhel64 ~]$ tail -f $ORACLE_BASE/diag/rdbms/prod/PROD/trace/alert_PROD.log
session 1:執(zhí)行commit命令,由于lgwr進程被掛起,commit命令hang住
SCOTT@PROD>commit;
session 2:再次查看test表中數據,能夠顯示出來
SCOTT@PROD>select * from test;
SCOTT@PROD>select count(*) from test;
從結果來看,之前看不到的那條記錄現(xiàn)在已經能看到了,即session 1對于session2而言已經commit了,盡管由于lgwr被掛起,session1的commit操作并沒有成功的做完。
Oracle 里 commit 操作時,
1、修改事務所對應的 undo segment header 中 slot 的狀態(tài);
2、改完狀態(tài)后再 flush log buffer;
session 3中把lgwr 掛起了,步驟2 無法完成,但步驟1還可以完成。
只要步驟1做完了,其他的 session 就能看到這個事務所做的改變了(通過ITL中記錄的 transaction id 去 check相應的 undo segment header 中 slot 的狀態(tài)),也就是說對于其他 session 而言,這個事務已經 commit 了,雖然這個事務其實并沒有成功commit。
(解除掛起lgwr進程,可以使用oradebug resume)
session 4:shutdown abort之后startup啟動實例
SYS@PROD>shutdown abort;
SYS@PROD>startup;
告警日志顯示有instance recovery
session 1:再次查看test表,數據不存在。
SCOTT@PROD>conn scott/tiger
SCOTT@PROD>select * from test;
SYS@PROD>oradebug help
HELP ? ? ? ? ? [command] ? ? ? ? ? ? ? ? Describe one or all commands
SETMYPID ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Debug current process
SETOSPID ? ? ? ? ? ? ? ? ? ? ? ? Set OS pid of process to debug
SETORAPID ? ? ? ['force'] ? ? ? ?Set Oracle pid of process to debug
SETORAPNAME ? ? ? ? ? ? ? ? ? ?Set Oracle process name to debug
SHORT_STACK ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Get abridged OS stack
CURRENT_SQL ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Get current SQL
DUMP ? ? ? ? ? [addr] ?Invoke named dump
DUMPSGA ? ? ? ?[bytes] ? ? ? ? ? ? ? ? ? Dump fixed SGA
DUMPLIST ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Print a list of available dumps
EVENT ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Set trace event in process
SESSION_EVENT ? ? ? ? ? ? ? ? ? ? ?Set trace event in session
DUMPVAR ? ? ? ?
[level] ?Print/dump a fixed PGA/SGA/UGA variable
DUMPTYPE ? ? ?
?Print/dump an address with type infoSETVAR ? ? ? ?
?Modify a fixed PGA/SGA/UGA variable
PEEK ? ? ? ? ? [level] ? ? ?Print/Dump memory
POKE ? ? ? ? ? ? ? ?Modify memory
WAKEUP ? ? ? ? ? ? ? ? ? ? ? ? ?Wake up Oracle process
SUSPEND ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Suspend execution
RESUME ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Resume execution
FLUSH ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Flush pending writes to trace file
CLOSE_TRACE ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Close trace file
TRACEFILE_NAME ? ? ? ? ? ? ? ? ? ? ? ? ? Get name of trace file
LKDEBUG ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Invoke global enqueue service debugger
NSDBX ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Invoke CGS name-service debugger
-G ? ? ? ? ? ? ? Parallel oradebug command prefix
-R ? ? ? ? ? ? ? Parallel oradebug prefix (return output
SETINST ? ? ? ? ? ? ?Set instance list in double quotes
SGATOFILE ? ? ? ? ? ? ? Dump SGA to file; dirname in double quotes
DMPCOWSGA ? ? ? Dump & map SGA as COW; dirname in double quotes
MAPCOWSGA ? ? ? ? ? ? ? Map SGA as COW; dirname in double quotes
HANGANALYZE ? ?[level] [syslevel] ? ? ? ?Analyze system hang
FFBEGIN ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Flash Freeze the Instance
FFDEREGISTER ? ? ? ? ? ? ? ? ? ? ? ? ? ? FF deregister instance from cluster
FFTERMINST ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Call exit and terminate instance
FFRESUMEINST ? ? ? ? ? ? ? ? ? ? ? ? ? ? Resume the flash frozen instance
FFSTATUS ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Flash freeze status of instance
SKDSTTPCS ? ? ? ? ? ? ? ?Helps translate PCs to names
WATCH ? ? ? ? ?
?Watch a region of memoryDELETE ? ? ? ? watchpoint ? ?Delete a watchpoint
SHOW ? ? ? ? ? watchpoints ? ? ? ?Show ?watchpoints
DIRECT_ACCESS ? Fixed table access
CORE ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Dump core without crashing process
IPC ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Dump ipc information
UNLIMIT ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Unlimit the size of the trace file
PROCSTAT ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Dump process statistics
CALL ? ? ? ? ? [-t count] [arg1]...[argn] ?Invoke function with arguments
SYS@PROD>
呂星昊
2016.3.27
總結
以上是生活随笔為你收集整理的oracle可以使用提交完成的事务,【体系结构】Oracle数据提交与事务隔离实验 oradebug挂起lgwr进程...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle sql比较时间大小,Ora
- 下一篇: php判断base64编码,检测PHP中