Oracle RAC环境下定位并杀掉最终阻塞的会话-续
之前在《Oracle RAC环境下定位并杀掉最终阻塞的会话》中,最终使用一个SQL查询出RAC实例之间的所有阻塞关系。但是实际在某些极端的生产环境,是不允许执行复杂的SQL语句,即使允许执行可能现场也不方便复制SQL,手敲的话效率低下,那么本文就介绍另一种简单的方法来快速定位最终阻塞会话,也就是DBA常用的oradebug hanganalyze。
1.模拟故障
直接根据《[Oracle RAC环境下定位并杀掉最终阻塞的会话](http://www.cnblogs.com/jyzhao/p/8716546.html)》中的来模拟,不再赘述。
如果按照之前的SQL查询,结果如下:
SYS@jyzhao1 >--cascade blocking@gv$session
SYS@jyzhao1 >select *
2 from (select a.inst_id, a.sid, a.serial#,
3 a.sql_id,
4 a.event,
5 a.status,
6 connect_by_isleaf as isleaf,
7 sys_connect_by_path(a.SID||'@'||a.inst_id, ' <- ') tree,
8 level as tree_level
9 from gv$session a
10 start with a.blocking_session is not null
11 connect by (a.sid||'@'||a.inst_id) = prior (a.blocking_session||'@'||a.blocking_instance))
12 where isleaf = 1
13 order by tree_level asc;
INST_ID SID SERIAL# SQL_ID EVENT STATUS ISLEAF TREE TREE_LEVEL
---------- ---------- ---------- ------------- ----------------------------------- -------- ---------- ------------------------------ ----------
1 26 3479 SQL*Net message from client INACTIVE 1 <- 148@2 <- 26@1 2
1 26 3479 SQL*Net message from client INACTIVE 1 <- 29@1 <- 148@2 <- 26@1 3
1 26 3479 SQL*Net message from client INACTIVE 1 <- 23@2 <- 148@2 <- 26@1 3
SYS@jyzhao1 >
2.oradebug hanganalyze
如今假设我们的环境的确不方便使用SQL查询,那么就需要用到oradebug hanganalyze来分析。
oradebug hanganalyze 3
因为我这里是RAC环境,需要分析所有实例:
oradebug -g all hanganalyze 3
SYS@jyzhao1 >oradebug -g all hanganalyze 3
Hang Analysis in /opt/app/oracle/diag/rdbms/jyzhao/jyzhao1/trace/jyzhao1_diag_1919.trc
3.分析trace文件
我们去分析这个生成的trc文件,可以很清楚的看到HANG分析部分,存在两个chain,比如我这个实验的情况就是:
Chain 1: 可以看到实例1的会话29被实例2的会话148阻塞,实例2的会话148又被实例1的会话26阻塞;
Chain 2: 可以看到实例2的会话23被实例2的会话148阻塞,而实例2的会话148又在第一个chain中。
可以发现这与我之前用SQL查询的结果是一样的意思,都可以做到快速定位最终阻塞会话是实例1的会话26,与客户确认后杀掉即可。
附:oradebug hanganalyze 3分析的trace文件中的核心信息
*** 2018-04-21 07:51:44.975
===============================================================================
HANG ANALYSIS:
instances (db_name.oracle_sid): jyzhao.jyzhao1, jyzhao.jyzhao2
oradebug_node_dump_level: 3
analysis initiated by oradebug
os thread scheduling delay history: (sampling every 1.000000 secs)
0.000000 secs at [ 07:51:44 ]
NOTE: scheduling delay has not been sampled for 0.305046 secs 0.000000 secs from [ 07:51:40 - 07:51:45 ], 5 sec avg
0.000000 secs from [ 07:50:45 - 07:51:45 ], 1 min avg
0.000000 secs from [ 07:46:45 - 07:51:45 ], 5 min avg
vktm time drift history
===============================================================================
Chains most likely to have caused the hang:
[a] Chain 1 Signature: 'SQL*Net message from client'<='enq: TX - row lock contention'<='enq: TX - row lock contention'
Chain 1 Signature Hash: 0x42598823
[b] Chain 2 Signature: 'SQL*Net message from client'<='enq: TX - row lock contention'<='enq: TX - row lock contention'
Chain 2 Signature Hash: 0x42598823
===============================================================================
Non-intersecting chains:
-------------------------------------------------------------------------------
Chain 1:
-------------------------------------------------------------------------------
Oracle session identified by:
{
instance: 1 (jyzhao.jyzhao1)
os id: 2712
process id: 42, oracle@jyrac1 (TNS V1-V3)
session id: 29
session serial #: 81
}
is waiting for 'enq: TX - row lock contention' with wait info:
{
p1: 'name|mode'=0x54580006
p2: 'usn<<16 | slot'=0xe0002
p3: 'sequence'=0x3a3
time in wait: 8 min 21 sec
timeout after: never
wait id: 37
blocking: 0 sessions
current sql: update emp set job = 'CEO' where empno = 7839
short stack: ksedsts()+465<-ksdxfstk()+32<-ksdxcb()+1927<-sspuser()+112<-__sighandler()<-semtimedop()+10<-skgpwwait()+178<-ksliwat()+2022<-kslwaitctx()+163<-k
jusuc()+3400<-ksipgetctxi()+1759<-ksqcmi()+20798<-ksqgtlctx()+3501<-ksqgelctx()+557<-ktuGetTxForXid()+131<-ktcwit1()+336<-kdddgb()+8587<-kdusru()+460<-kauupd()+412<-updrow
()+2167<-qerupFetch()+860<-updaul()+1378<-updThreePhaseExe()+318<-updexe()+638<-opiexe()+10378<-kpoal8()+2380<-opiodr()+917<-ttcpip()+2183<-opitsk()+1710<-opiino()+969<-op
iodr()+917<-opidrv()+570<-sou2o(
wait history:
* time between current wait and wait #1: 0.010123 sec
1. event: 'gc current block 2-way'
time waited: 0.000622 sec
wait id: 36 p1: ''=0x7
p2: ''=0x6483
p3: ''=0x2000001
* time between wait #1 and #2: 0.007260 sec
2. event: 'gc cr block 2-way'
time waited: 0.000501 sec
wait id: 35 p1: ''=0x6
p2: ''=0x523
p3: ''=0x2c
* time between wait #2 and #3: 0.000462 sec
3. event: 'gc cr block 2-way'
time waited: 0.000689 sec
wait id: 34 p1: ''=0x6
p2: ''=0xb0
p3: ''=0x2b
}
and is blocked by
=> Oracle session identified by:
{
instance: 2 (jyzhao.jyzhao2)
os id: 23427
process id: 41, oracle@jyrac2 (TNS V1-V3)
session id: 148
session serial #: 17715
}
which is waiting for 'enq: TX - row lock contention' with wait info:
{
p1: 'name|mode'=0x54580006
p2: 'usn<<16 | slot'=0x50008
p3: 'sequence'=0x9e6
time in wait: 9 min 9 sec
timeout after: never
wait id: 152
blocking: 2 sessions
current sql: update emp set job = 'MANAGER' where empno = 7788
short stack: ksedsts()+465<-ksdxfstk()+32<-ksdxcb()+1927<-sspuser()+112<-__sighandler()<-semtimedop()+10<-skgpwwait()+178<-ksliwat()+2022<-kslwaitctx()+163<-k
jusuc()+3400<-ksipgetctxi()+1759<-ksqcmi()+20798<-ksqgtlctx()+3501<-ksqgelctx()+557<-ktuGetTxForXid()+131<-ktcwit1()+336<-kdddgb()+8587<-kdusru()+460<-kauupd()+412<-updrow
()+2167<-qerupFetch()+860<-updaul()+1378<-updThreePhaseExe()+318<-updexe()+638<-opiexe()+10378<-kpoal8()+2380<-opiodr()+917<-ttcpip()+2183<-opitsk()+1710<-opiino()+969<-op
iodr()+917<-opidrv()+570<-sou2o(
wait history:
* time between current wait and wait #1: 0.005023 sec
1. event: 'gc cr block 2-way'
time waited: 0.000478 sec
wait id: 151 p1: ''=0x3
p2: ''=0xc0
p3: ''=0x19
* time between wait #1 and #2: 0.000295 sec
2. event: 'gc cr block 2-way'
time waited: 0.000821 sec
wait id: 150 p1: ''=0x3
p2: ''=0x362
p3: ''=0x1a
* time between wait #2 and #3: 0.000294 sec
3. event: 'gc cr block 2-way'
time waited: 0.000431 sec
wait id: 149 p1: ''=0x3
p2: ''=0xc0
p3: ''=0x19
}
and is blocked by
=> Oracle session identified by:
{
instance: 1 (jyzhao.jyzhao1)
os id: 1648
process id: 32, oracle@jyrac1 (TNS V1-V3)
session id: 26
session serial #: 3479
}
which is waiting for 'SQL*Net message from client' with wait info:
{
p1: 'driver id'=0x62657100
p2: '#bytes'=0x1
time in wait: 9 min 28 sec
timeout after: never
wait id: 168
blocking: 3 sessions
current sql: <none>
short stack: ksedsts()+465<-ksdxfstk()+32<-ksdxcb()+1927<-sspuser()+112<-__sighandler()<-read()+14<-ntpfprd()+117<-nsbasic_brc()+376<-nsbrecv()+69<-nioqrc()+4
95<-opikndf2()+978<-opitsk()+831<-opiino()+969<-opiodr()+917<-opidrv()+570<-sou2o()+103<-opimai_real()+133<-ssthrdmain()+265<-main()+201<-__libc_start_main()+253
wait history:
* time between current wait and wait #1: 0.000010 sec
1. event: 'SQL*Net message to client'
time waited: 0.000003 sec
wait id: 167 p1: 'driver id'=0x62657100
p2: '#bytes'=0x1
* time between wait #1 and #2: 0.000239 sec
2. event: 'gc current grant 2-way'
time waited: 0.000337 sec
wait id: 166 p1: ''=0x7
p2: ''=0x6483
p3: ''=0x2010001
* time between wait #2 and #3: 0.000196 sec
3. event: 'db file sequential read'
time waited: 0.000824 sec
wait id: 165 p1: 'file#'=0x7
p2: 'block#'=0x6483
p3: 'blocks'=0x1
}
Chain 1 Signature: 'SQL*Net message from client'<='enq: TX - row lock contention'<='enq: TX - row lock contention'
Chain 1 Signature Hash: 0x42598823
-------------------------------------------------------------------------------
===============================================================================
Intersecting chains:
-------------------------------------------------------------------------------
Chain 2:
-------------------------------------------------------------------------------
Oracle session identified by:
{
instance: 2 (jyzhao.jyzhao2)
os id: 23488
process id: 42, oracle@jyrac2 (TNS V1-V3)
session id: 23
session serial #: 12635
}
is waiting for 'enq: TX - row lock contention' with wait info:
{
p1: 'name|mode'=0x54580006
p2: 'usn<<16 | slot'=0xe0002
p3: 'sequence'=0x3a3
time in wait: 8 min 34 sec
timeout after: never
wait id: 39
blocking: 0 sessions
current sql: update emp set sal = 15000 where empno = 7839
short stack: ksedsts()+465<-ksdxfstk()+32<-ksdxcb()+1927<-sspuser()+112<-__sighandler()<-semtimedop()+10<-skgpwwait()+178<-ksliwat()+2022<-kslwaitctx()+163<-k
jusuc()+3400<-ksipgetctxi()+1759<-ksqcmi()+20798<-ksqgtlctx()+3501<-ksqgelctx()+557<-ktuGetTxForXid()+131<-ktcwit1()+336<-kdddgb()+8587<-kdusru()+460<-kauupd()+412<-updrow
()+2167<-qerupFetch()+860<-updaul()+1378<-updThreePhaseExe()+318<-updexe()+638<-opiexe()+10378<-kpoal8()+2380<-opiodr()+917<-ttcpip()+2183<-opitsk()+1710<-opiino()+969<-op
iodr()+917<-opidrv()+570<-sou2o(
wait history:
* time between current wait and wait #1: 0.000226 sec
1. event: 'gc cr block 2-way'
time waited: 0.000605 sec
wait id: 38 p1: ''=0x3
p2: ''=0xc0
p3: ''=0x19
* time between wait #1 and #2: 0.011878 sec
2. event: 'gc cr block 2-way'
time waited: 0.000610 sec
wait id: 37 p1: ''=0x3
p2: ''=0xc0
p3: ''=0x19
* time between wait #2 and #3: 0.000316 sec
3. event: 'Disk file operations I/O'
time waited: 0.000007 sec
wait id: 36 p1: 'FileOperation'=0x2
p2: 'fileno'=0x3
p3: 'filetype'=0x2
}
and is blocked by 'instance: 2, os id: 23427, session id: 148',
which is a member of 'Chain 1'.
Chain 2 Signature: 'SQL*Net message from client'<='enq: TX - row lock contention'<='enq: TX - row lock contention'
Chain 2 Signature Hash: 0x42598823
-------------------------------------------------------------------------------
===============================================================================
可以看到这种oradebug hanganalyze生成的trc文件并没有那么的难理解,反而这种chain的描述更加清楚,身为一名专业的Oracle DBA,我们是必须要掌握这种方法的。
Oracle RAC环境下定位并杀掉最终阻塞的会话-续的更多相关文章
- Oracle RAC环境下定位并杀掉最终阻塞的会话
实验环境:Oracle RAC 11.2.0.4 (2节点) 1.模拟故障:会话被级联阻塞 2.常规方法:梳理找出最终阻塞会话 3.改进方法:立即找出最终阻塞会话 之前其实也写过一篇相关文章: 如何定 ...
- 【转】Oracle RAC 环境下的连接管理
文章转自:http://www.oracle.com/technetwork/cn/articles/database-performance/oracle-rac-connection-mgmt-1 ...
- Oracle RAC 环境下的连接管理(转) --- 防止原文连接失效
崔华老师的文章!!! 这篇文章详细介绍了Oracle RAC环境下的连接管理,分别介绍了什么是 Connect Time Load Balancing.Runtime Connection Load ...
- bay——Oracle RAC环境下ASM磁盘组扩容.docx
https://www.cnblogs.com/polestar/p/10115263.html Oracle RAC环境下ASM磁盘组扩容 生产环境注意调整以下参数: +++++++++++++++ ...
- Oracle RAC 环境下的 v$log v$logfile
通常情况下,在Oracle RAC 环境中,v$视图可查询到你所连接实例的相关信息,而gv$视图则包含所有实例的信息.然而在RAC环境中,当我们查询v$log视图时说按照常理的话,v$log视图应当看 ...
- Oracle RAC环境下如何更新patch(Rolling Patch)
Oracle RAC数据库环境与单实例数据库环境有很多共性,也有很多异性.对于数据库补丁的更新同样如此,都可以通过opatch来完成.但RAC环境的补丁更新有几种不同的更新方式,甚至于可以在零停机的情 ...
- Oracle RAC环境下怎样更新patch(Rolling Patch)
Oracle RAC数据库环境与单实例数据库环境有非常多共性,也有非常多异性.对于数据库补丁的更新相同如此.都能够通过opatch来完毕.但RAC环境的补丁更新有几种不同的更新方式,甚至于能够 ...
- Oracle RAC环境下ASM磁盘组扩容
生产环境注意调整以下参数: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 在oracle RAC 环境下用 PL/SQL Developer debug procedure 出现 hang 的情况
现象描述: 用plsql developer 连接编译procedure 的时候都很正常.一旦开始Test进入Debug模式的时候就Hang住了. 初步猜测是没有权限,可是是DBA角色呀,如果没有权限 ...
随机推荐
- New UWP Community Toolkit - Markdown
概述 前面 New UWP Community Toolkit 文章中,我们对 V2.2.0 版本的重要更新做了简单回顾,其中简单介绍了 MarkdownTextBlock 和 MarkdownDoc ...
- [日常] NOIP 2017滚粗记
突然挑了这么个滑稽的时间补了游记... (成绩日常延时再加上人太菜估计基本上就是颓废记录) 然而文化课太废可能会被强制退役QAQ所以先补了再说吧 day0 一大早被老姚交代了个开十一机房门的任务... ...
- 四则运算程序(java基于控制台)
四则运算题目生成程序(基于控制台) 一.题目描述: 1. 使用 -n 参数控制生成题目的个数,例如 Myapp.exe -n 10 -o Exercise.txt 将生成10个题目. 2. 使用 -r ...
- Java Client/Server 基础知识
Java的网络类库支持多种Internet协议,包括Telnet, FTP 和HTTP (WWW),与此相对应的Java网络类库的子类库为: Java.net Java.net.ftp Java. ...
- 十、Python练习----基础搭建飞机大战
只是简单的学习了pygame,实现飞机的摧毁还需要多张图片的切换,和sprite(碰撞精灵),还有多种音效的添加(如背景音乐.摧毁特效).以后再深入学习我只是练习一下python. 一.搭建界面(基于 ...
- nyoj 寻找最大数(二)
寻找最大数(二) 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 给你一个数字n(可能有前缀0). 要求从高位到低位,进行 进栈出栈 操作,是最后输出的结果最大. ...
- vue style width a href动态拼接问题 ?
style width 这个问题 折磨了我一个上午了 好惭愧 因为项目涉及到 进度条 所以必须用行内样式 style 用过vue的都知道 vue中style的用法 大众用法 :style=&quo ...
- 使用静态基类方案让 ASP.NET Core 实现遵循 HATEOAS Restful Web API
Hypermedia As The Engine Of Application State (HATEOAS) HATEOAS(Hypermedia as the engine of applicat ...
- 算法题丨3Sum
描述 Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all ...
- Python内置函数(7)——sum
英文文档: sum(iterable[, start]) Sums start and the items of an iterable from left to right and returns ...