标签云
asm恢复 bbed bootstrap$ dul In Memory kcbzib_kcrsds_1 kccpb_sanity_check_2 MySQL恢复 ORA-00312 ORA-00607 ORA-00704 ORA-00742 ORA-01110 ORA-01555 ORA-01578 ORA-08103 ORA-600 2131 ORA-600 2662 ORA-600 2663 ORA-600 3020 ORA-600 4000 ORA-600 4137 ORA-600 4193 ORA-600 4194 ORA-600 16703 ORA-600 kcbzib_kcrsds_1 ORA-600 KCLCHKBLK_4 ORA-15042 ORA-15196 ORACLE 12C oracle dul ORACLE PATCH Oracle Recovery Tools oracle加密恢复 oracle勒索 oracle勒索恢复 oracle异常恢复 Oracle 恢复 ORACLE恢复 ORACLE数据库恢复 oracle 比特币 OSD-04016 YOUR FILES ARE ENCRYPTED 勒索恢复 比特币加密文章分类
- Others (2)
- 中间件 (2)
- WebLogic (2)
- 操作系统 (103)
- 数据库 (1,703)
- DB2 (22)
- MySQL (74)
- Oracle (1,564)
- Data Guard (52)
- EXADATA (8)
- GoldenGate (24)
- ORA-xxxxx (159)
- ORACLE 12C (72)
- ORACLE 18C (6)
- ORACLE 19C (15)
- ORACLE 21C (3)
- Oracle 23ai (8)
- Oracle ASM (68)
- Oracle Bug (8)
- Oracle RAC (53)
- Oracle 安全 (6)
- Oracle 开发 (28)
- Oracle 监听 (28)
- Oracle备份恢复 (571)
- Oracle安装升级 (94)
- Oracle性能优化 (62)
- 专题索引 (5)
- 勒索恢复 (81)
- PostgreSQL (18)
- PostgreSQL恢复 (6)
- SQL Server (27)
- SQL Server恢复 (8)
- TimesTen (7)
- 达梦数据库 (2)
- 生活娱乐 (2)
- 至理名言 (11)
- 虚拟化 (2)
- VMware (2)
- 软件开发 (37)
- Asp.Net (9)
- JavaScript (12)
- PHP (2)
- 小工具 (20)
-
最近发表
- 处理 Oracle 块损坏
- Oracle各种类型坏块说明和处理
- fio测试io,导致磁盘文件系统损坏故障恢复
- ORA-742 写丢失常见bug记录
- Oracle 19c 202501补丁(RUs+OJVM)-19.26
- 避免 19c 数据库性能问题需要考虑的事项 (Doc ID 3050476.1)
- Bug 21915719 Database hang or may fail to OPEN in 12c IBM AIX or HPUX Itanium – ORA-742, DEADLOCK or ORA-600 [kcrfrgv_nextlwn_scn] ORA-600 [krr_process_read_error_2]
- ORA-600 ktuPopDictI_1恢复
- impdp导入数据丢失sys授权问题分析
- impdp 创建index提示ORA-00942: table or view does not exist
- 数据泵导出 (expdp) 和导入 (impdp)工具性能降低分析参考
- 19c非归档数据库断电导致ORA-00742故障恢复
- Oracle 19c – 手动升级到 Non-CDB Oracle Database 19c 的完整核对清单
- sqlite数据库简单操作
- Oracle 暂定和恢复功能
- .pzpq扩展名勒索恢复
- Oracle read only用户—23ai新特性:只读用户
- 迁移awr快照数据到自定义表空间
- .hmallox加密mariadb/mysql数据库恢复
- 2025年首个故障恢复—ORA-600 kcbzib_kcrsds_1
分类目录归档:Oracle性能优化
Hanganalyze分析会话阻塞—锁表
前两篇分别大概的介绍了Systemstates分析会话阻塞—锁表和使用ass109.awk分析systemstate,这篇也大概的学习下hanganalyze.
模拟阻塞会话
--会话1 SQL> select * from v$version; BANNER ------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production PL/SQL Release 11.2.0.3.0 - Production CORE 11.2.0.3.0 Production TNS for Linux: Version 11.2.0.3.0 - Production NLSRTL Version 11.2.0.3.0 - Production SQL> select * from t_xifenfei; ID NAME ---------- ---------------------------------------- 1 xifenfei 2 www.xifenfei SQL> delete from t_xifenfei where id=2; 1 row deleted. --会话2 SQL> delete from t_xifenfei where id=2; --hang住
做hanganalyze
--sys登录 SQL> ORADEBUG setmypid Statement processed. SQL> oradebug unlimit; Statement processed. SQL> oradebug hanganalyze 3 Hang Analysis in /u01/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_13719.trc
分析hanganalyze 文件
--HANG ANALYSIS基本信息 =============================================================================== HANG ANALYSIS: instances (db_name.oracle_sid): ora11g.ora11g oradebug_node_dump_level: 3 analysis initiated by oradebug os thread scheduling delay history: (sampling every 1.000000 secs) 0.000000 secs at [ 15:53:16 ] NOTE: scheduling delay has not been sampled for 0.356486 secs 0.000000 secs from [ 15:53:12 - 15:53:17 ], 5 sec avg 0.000000 secs from [ 15:52:17 - 15:53:17 ], 1 min avg 0.000000 secs from [ 15:48:17 - 15:53:17 ], 5 min avg =============================================================================== Chains most likely to have caused the hang: [a] Chain 1 Signature: 'SQL*Net message from client'<='enq: TX - row lock contention' Chain 1 Signature Hash: 0x38c48850 =============================================================================== Non-intersecting chains: ------------------------------------------------------------------------------- Chain 1: ------------------------------------------------------------------------------- --被阻塞会话信息 Oracle session identified by: { instance: 1 (ora11g.ora11g) os id: 13634 process id: 21, oracle@xifenfei (TNS V1-V3) session id: 143 session serial #: 281 } --等待信息 is waiting for 'enq: TX - row lock contention' with wait info: { p1: 'name|mode'=0x54580006 --54580006 is split into ASCII 54 + ASCII 58 (TX) + Mode 0006 (X) ... 在等待TX mode=6 p2: 'usn<<16 | slot'=0x20010 p3: 'sequence'=0x356 time in wait: 1 min 56 sec timeout after: never wait id: 24 blocking: 0 sessions current sql: delete from t_xifenfei where id=2 short stack: --省略 wait history: * time between current wait and wait #1: 0.001471 sec 1. event: 'SQL*Net message from client' time waited: 10.776765 sec wait id: 23 p1: 'driver id'=0x62657100 p2: '#bytes'=0x1 * time between wait #1 and #2: 0.000001 sec 2. event: 'SQL*Net message to client' time waited: 0.000001 sec wait id: 22 p1: 'driver id'=0x62657100 p2: '#bytes'=0x1 * time between wait #2 and #3: 0.000028 sec 3. event: 'SQL*Net message from client' time waited: 0.000032 sec wait id: 21 p1: 'driver id'=0x62657100 p2: '#bytes'=0x1 } and is blocked by => Oracle session identified by: --阻塞会话信息 { instance: 1 (ora11g.ora11g) os id: 13546 process id: 20, oracle@xifenfei (TNS V1-V3) session id: 15 session serial #: 189 } --该会话处于空闲状态 which is waiting for 'SQL*Net message from client' with wait info: { p1: 'driver id'=0x62657100 p2: '#bytes'=0x1 time in wait: 2 min 26 sec timeout after: never wait id: 29 blocking: 1 session current sql: <none> short stack: --省略 wait history: * time between current wait and wait #1: 0.000019 sec 1. event: 'SQL*Net message to client' time waited: 0.000007 sec wait id: 28 p1: 'driver id'=0x62657100 p2: '#bytes'=0x1 * time between wait #1 and #2: 0.049656 sec 2. event: 'SQL*Net message from client' time waited: 9.759067 sec wait id: 27 p1: 'driver id'=0x62657100 p2: '#bytes'=0x1 * time between wait #2 and #3: 0.000216 sec 3. event: 'SQL*Net message to client' time waited: 0.000002 sec wait id: 26 p1: 'driver id'=0x62657100 p2: '#bytes'=0x1 } Chain 1 Signature: 'SQL*Net message from client'<='enq: TX - row lock contention' Chain 1 Signature Hash: 0x38c48850 ------------------------------------------------------------------------------- =============================================================================== 通过上述分析:大概可以得出sid=143因为请求enq: TX - row lock contention(TX mode=6)被sid=15阻塞
查询视图验证
SQL> select sid,event from v$session where wait_class#<>6; SID EVENT ---------- ------------------------------ 20 SQL*Net message to client 143 enq: TX - row lock contention SQL> select * from v$lock where type in('TX','TM'); ADDR KADDR SID TYPE ID1 ID2 LMODE REQUEST CTIME BLOCK -------- -------- ---------- ---- ---------- ---------- ---------- ---------- ---------- ---------- 352F8BEC 352F8C18 143 TX 131088 854 0 6 1862 0 B6B9C7A8 B6B9C7D8 15 TM 75928 0 3 0 1892 0 B6B9C7A8 B6B9C7D8 143 TM 75928 0 3 0 1862 0 343C0E54 343C0E94 15 TX 131088 854 6 0 1892 1 --查询结果sid=15的会话持有TX MODE=6阻塞sid=143的TX MODE=6的请求,和HANG ANALYSIS分析基本一致
参考文档:USING AND READING HANGANALYZE或者[ID 215858.1]
发表在 Oracle性能优化
评论关闭
使用ass109.awk分析systemstate
本篇介绍工具ass109.awk使用,大大节约分析systemstate dump文件时间.当然如果要获得详细信息,还是需要人工去读相关进程的dump文件.
模拟会话被hang住
--会话1 SQL> select * from t_xifenfei; ID NAME ---------- ---------------------------------------- 1 xifenfei 2 www.xifenfei SQL> delete from t_xifenfei where id=1; 1 row deleted. --会话2 SQL> delete from t_xifenfei where id=1; --hang住
做systemstate
SQL> oradebug setmypid Statement processed. SQL> oradebug unlimit Statement processed. SQL> oradebug dump systemstate 10 Statement processed. SQL> oradebug tracefile_name /u01/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_9976.trc SQL> exit
使用ass109.awk分析dump文件
[oracle@xifenfei ~]$ awk -f ass109.awk /u01/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_9976.trc Starting Systemstate 1 .................................. Ass.Awk Version 1.0.9 - Processing /u01/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_9976.trc System State 1 ~~~~~~~~~~~~~~~~ 1: 2: 0: waiting for 'pmon timer' 3: 0: waiting for 'rdbms ipc message' 4: 0: waiting for 'VKTM Logical Idle Wait' 5: 0: waiting for 'rdbms ipc message' 6: 0: waiting for 'DIAG idle wait' 7: 0: waiting for 'rdbms ipc message' 8: 0: waiting for 'DIAG idle wait' 9: 0: waiting for 'rdbms ipc message' 10: 0: waiting for 'rdbms ipc message' 11: 0: waiting for 'rdbms ipc message' 12: 0: waiting for 'rdbms ipc message' 13: 0: waiting for 'smon timer' 14: 0: waiting for 'rdbms ipc message' 15: 0: waiting for 'rdbms ipc message' 16: 0: waiting for 'rdbms ipc message' 17: 18: 19: 0: waiting for 'Space Manager: slave idle wait' 20: 0: waiting for 'SQL*Net message from client' 21: 0: waiting for 'enq: TX - row lock contention'[Enqueue TX-000A0020-0000024F] Cmd: Delete 22: 0: waiting for 'rdbms ipc message' 23: 0: waiting for 'rdbms ipc message' 24: 0: waiting for 'rdbms ipc message' 25: 0: waiting for 'rdbms ipc message' 26: 0: waiting for 'Streams AQ: qmn coordinator idle wait' 27: 28: 30: 0: waiting for 'Streams AQ: qmn slave idle wait' 31: 0: waiting for 'rdbms ipc message' 33: 1: waited for 'Streams AQ: waiting for time management or cleanup tasks' 35: 0: waiting for 'rdbms ipc message' 41: 44: Blockers ~~~~~~~~ Above is a list of all the processes. If they are waiting for a resource then it will be given in square brackets. Below is a summary of the waited upon resources, together with the holder of that resource. Notes: ~~~~~ o A process id of '???' implies that the holder was not found in the systemstate. Resource Holder State Enqueue TX-000A0020-0000024F 20: 0: waiting for 'SQL*Net message from client' Object Names ~~~~~~~~~~~~ Enqueue TX-000A0020-0000024F 30586 Lines Processed. --从这里马上就可以知道pid 21 请求Enqueue TX被pid 20阻塞
下载:ass109.awk
Systemstates分析会话阻塞—锁表
模拟会话被阻塞
--会话1 SQL> select sid from v$mystat where rownum=1; SID ---------- 15 SQL> create table t_xifenfei (id number,name varchar2(20)); Table created. SQL> insert into t_xifenfei values(1,'xifenfei'); 1 row created. SQL> insert into t_xifenfei values(2,'www.xifenfei'); 1 row created. SQL> commit; Commit complete. SQL> select * from t_xifenfei; ID NAME ---------- ---------------------------------------- 1 xifenfei 2 www.xifenfei SQL> delete from t_xifenfei where id=1; 1 row deleted. --会话2 SQL> select sid from v$mystat where rownum=1; SID ---------- 143 SQL> delete from chf.t_xifenfei where id=1; --hang住
新打开会话做Systemstates
我们假设不知道会话1和会话2的sid,现在特定的使用Systemstates分析问题,后面给出简单分析方法
SQL> oradebug setmypid Statement processed. SQL> oradebug unlimit Statement processed. SQL> oradebug dump systemstate 10 Statement processed. SQL> oradebug dump systemstate 10 Statement processed. SQL> oradebug tracefile_name /u01/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_31027.trc SQL> exit
阅读trace文件
会话2在这样的情况下hang住,而其他会话正常,第一反应是在lock级别阻塞了,而这个又是DML操作,很自然想到是TX,于是在trace文件中搜索”enq: TX” ,找到对应记录,然后向上找到对应的进程号,开始读相关内容,发现有小信息如下:
PROCESS 20: ---------------------------------------- --客户端信息 client details: O/S info: user: oracle, term: pts/0, ospid: 30622 machine: xifenfei program: sqlplus@xifenfei (TNS V1-V3) application name: SQL*Plus, hash value=3669949024 --进程相关session信息 (session) sid: 15 ser: 151 trans: 0x343a4c2c, creator: 0x35fe2218 flags: (0x45) USR/- flags_idl: (0x0) -/-/-/-/-/- flags2: (0x40009) -/-/INC DID: , short-term DID: txn branch: (nil) oct: 0, prv: 0, sql: (nil), psql: 0x2f6e7b68, user: 84/CHF --被阻塞会话信息 There are 1 sessions blocked by this session. Dumping one waiter: inst: 1, sid: 143, ser: 229 wait event: 'enq: TX - row lock contention' p1: 'name|mode'=0x54580006 p2: 'usn<<16 | slot'=0x40005 p3: 'sequence'=0x252 row_wait_obj#: 75928, block#: 171, row#: 0, file# 4 min_blocked_time: 296 secs, waiter_cache_ver: 7860 Wait State: fixed_waits=0 flags=0x22 boundary=(nil)/-1 --54580006 is split into ASCII 54 + ASCII 58 (TX) + Mode 0006 (X) ... SQL> select object_type,object_name,owner from dba_objects where object_id=75928; OBJECT_TYP OBJECT_NAME OWNER ---------- -------------------- ---------- TABLE T_XIFENFEI CHF --持有锁的信息 (enqueue) TX-00040005-00000252 DID: 0001-0014-0000009C lv: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 res_flag: 0x6 mode: X, lock_flag: 0x0, lock: 0x343a4c6c, res: 0x353606a8 own: 0x355ae5b8, sess: 0x355ae5b8, proc: 0x35fe2218, prv: 0x353606b0 --通过上述信息可以分析出结论: sqlplus登录的sid=15的会话占用了TX mode=6(mode:x)的锁,阻塞了sid=143会话对chf.t_xifenfei表操作
找出被阻塞进程相关信息(sid 为143的进程),搜索”sid: 143″,阅读相关进程信息
PROCESS 21: ---------------------------------------- --相关session信息 (session) sid: 143 ser: 229 trans: 0x343915a0, creator: 0x35fe2d3c flags: (0x41) USR/- flags_idl: (0x1) BSY/-/-/-/-/- flags2: (0x40009) -/-/INC DID: , short-term DID: txn branch: (nil) oct: 7, prv: 0, sql: 0x2f6cb234, psql: 0x2f6dd5cc, user: 0/SYS --当前等待信息 Current Wait Stack: 0: waiting for 'enq: TX - row lock contention' name|mode=0x54580006, usn<<16 | slot=0x40005, sequence=0x252 wait_id=12 seq_num=13 snap_id=1 wait times: snap=5 min 1 sec, exc=5 min 1 sec, total=5 min 1 sec wait times: max=infinite, heur=5 min 1 sec wait counts: calls=101 os=101 in_wait=1 iflags=0x15a0 --阻塞该会话的session信息 There is at least one session blocking this session. Dumping 1 direct blocker(s): inst: 1, sid: 15, ser: 151 Dumping final blocker: inst: 1, sid: 15, ser: 151 Wait State: fixed_waits=0 flags=0x22 boundary=(nil)/-1 --请求锁信息 SO: 0x352f8fcc, type: 8, owner: 0x35765fe8, flag: INIT/-/-/0x00 if: 0x1 c: 0x1 proc=0x35fe2d3c, name=enqueue, file=ksq1.h LINE:380, pg=0 (enqueue) TX-00040005-00000252 DID: 0001-0015-0000003B lv: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 res_flag: 0x6 req: X, lock_flag: 0x10, lock: 0x352f8ff8, res: 0x353606a8 own: 0x356f49b8, sess: 0x356f49b8, proc: 0x35fe2d3c, prv: 0x353606b8 --通过对被阻塞对象分析,可以得出和阻塞者相同的信息
对该问题的常规分析思路
--查询等待事件 SQL> select event,p1,p2,p3 from v$session where wait_class#<>6; EVENT P1 P2 P3 ------------------------------ ---------- ---------- ---------- SQL*Net message to client 1650815232 1 0 enq: TX - row lock contention 1415053318 262149 594 --查询锁信息(因为通过上面的等待事件分析,TX可能引起会话hang) SQL> SELECT * FROM v$lock where type in ('TM','TX'); ADDR KADDR SID TYPE ID1 ID2 LMODE REQUEST CTIME BLOCK -------- -------- ---------- ---- ---------- ---------- ---------- ---------- ---------- ---------- 352F8FCC 352F8FF8 143 TX 262149 594 0 6 4181 0 B69CC7A8 B69CC7D8 143 TM 75928 0 3 0 4181 0 B69CC7A8 B69CC7D8 15 TM 75928 0 3 0 4266 0 343A4C2C 343A4C6C 15 TX 262149 594 6 0 4267 1 --通过TM查询出来对应对象 SQL> select object_type,object_name,owner from dba_objects where object_id=75928; OBJECT_TYP OBJECT_NAME OWNER ---------- -------------------- ---------- TABLE T_XIFENFEI CHF --通过观察v$lock查询结果可以知道: 15会话的TX MODE=6的锁阻塞了143会话想会的的TX MODE=6的锁,从而是的143会话hang住
Systemstates分析参考文档:Understanding and Reading Systemstates或者[ID 423153.1]
发表在 Oracle性能优化
一条评论