数据库学习日常案例20231206- 单实例oradebug hanganalize 3 分析

1 创建测试存储过程

SQL> create or replace procedure p0001 as
  2  begin
  3  dbms_lock.sleep(300000); --1000 seconds
  4  end;
  5  /

过程已创建。

2 session1调用存储过程

call p0001();

3 SESSION2和3分被对存储进行重新编译。

SQL> alter procedure p0001 compile;

发现编译存储过程均被hang住。

4 使用oradebug hanganalyze 3分析

SQL> oradebug hanganalyze 3;
Hang Analysis in D:\APP\ADMINISTRATOR\VIRTUAL\diag\rdbms\oprod\oprod\trace\oprod_ora_10320.trc
SQL> exit
从 Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production 断开

C:\Users\Administrator>

5 分析trc文件

Trace file D:\APP\ADMINISTRATOR\VIRTUAL\diag\rdbms\oprod\oprod\trace\oprod_ora_10320.trc
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Build label:    RDBMS_12.2.0.1.0_WINDOWS.X64_170210.4
Windows NT Version V6.1 Service Pack 1 
ORACLE_HOME =  D:\app\Administrator\virtual\product\12.2.0\dbhome_1
Node name           : UP57VFMG5AH8GDS
CPU                 : 4 - type 8664, 2 Physical Cores
Process Affinity    : 0x0x0000000000000000
Memory (Ava
Instance name: oprod
Redo thread mounted by this instance: 1
Oracle process number: 54
Windows thread id: 10320, image: ORACLE.EXE (SHAD)


*** 2023-12-06T15:52:29.155541+08:00
*** SESSION ID:(262.24957) 2023-12-06T15:52:29.155541+08:00
*** CLIENT ID:() 2023-12-06T15:52:29.155541+08:00
*** SERVICE NAME:(SYS$USERS) 2023-12-06T15:52:29.155541+08:00
*** MODULE NAME:(sqlplus.exe) 2023-12-06T15:52:29.155541+08:00
*** ACTION NAME:() 2023-12-06T15:52:29.155541+08:00
*** CLIENT DRIVER:(SQL*PLUS) 2023-12-06T15:52:29.155541+08:00
 
Processing Oradebug command 'setmypid'

*** 2023-12-06T15:52:29.156541+08:00
Oradebug command 'setmypid' console output:

*** 2023-12-06T15:52:54.968017+08:00
Processing Oradebug command 'hanganalyze level 3'

*** 2023-12-06T15:52:54.971017+08:00
Error while executing Oradebug command 'hanganalyze level 3':
ORA-01858: 鍦ㄨ姹傝緭鍏ユ暟瀛楀鎵惧埌闈炴暟瀛楀瓧绗?

*** 2023-12-06T15:52:54.972017+08:00
Oradebug command 'hanganalyze level 3' console output:

*** 2023-12-06T15:52:59.373269+08:00
Processing Oradebug command 'hanganalyze '

*** 2023-12-06T15:52:59.374269+08:00
===============================================================================
HANG ANALYSIS:
  instances (db_name.oracle_sid): oprod.oprod
  no oradebug node dumps
  analysis initiated by oradebug
  os thread scheduling delay history: (sampling every 1.000000 secs)
    0.000000 secs at [ 15:52:59 ]
      NOTE: scheduling delay has not been sampled for 0.222575 secs
    0.000000 secs from [ 15:52:55 - 15:53:00 ], 5 sec avg
    0.000000 secs from [ 15:51:59 - 15:53:00 ], 1 min avg
    0.000000 secs from [ 15:47:59 - 15:53:00 ], 5 min avg
  vktm time drift history
===============================================================================
 
Chains most likely to have caused the hang:
 [a] Chain 1 Signature: 'PL/SQL lock timer'<='library cache pin'<='library cache lock'
     Chain 1 Signature Hash: 0x38f0a7dd
 
===============================================================================
Non-intersecting chains:
 
-------------------------------------------------------------------------------
Chain 1:
-------------------------------------------------------------------------------
    Oracle session identified by:
    {
                instance: 1 (oprod.oprod)
                   os id: 2880
              process id: 27, ORACLE.EXE (SHAD)
              session id: 389
        session serial #: 26175
    }
    is waiting for 'library cache lock' with wait info:
    {
                      p1: 'handle address'=0x7ff13aebae8
                      p2: 'lock address'=0x7ff143eb1d0
                      p3: '100*mode+namespace'=0x130ce00010003
            time in wait: 1 min 4 sec
           timeout after: 13 min 55 sec
                 wait id: 18
                blocking: 0 sessions
            wait history:
              * time between current wait and wait #1: 0.000332 sec
              1.       event: 'PGA memory operation'
                 time waited: 0.000006 sec
                     wait id: 17               p1: ''=0x10000
                                               p2: ''=0x2
              * time between wait #1 and #2: 0.000017 sec
              2.       event: 'PGA memory operation'
                 time waited: 0.000004 sec
                     wait id: 16               p1: ''=0x10000
                                               p2: ''=0x1
              * time between wait #2 and #3: 0.002372 sec
              3.       event: 'SQL*Net message from client'
                 time waited: 1 min 58 sec
                     wait id: 15               p1: 'driver id'=0x42455100
                                               p2: '#bytes'=0x1
    }
    and is blocked by
 => Oracle session identified by:
    {
                instance: 1 (oprod.oprod)
                   os id: 13020
              process id: 56, ORACLE.EXE (SHAD)
              session id: 15
        session serial #: 38764
    }

alter system kill session '15,38764' immediate;
    which is waiting for 'library cache pin' with wait info:
    {
                      p1: 'handle address'=0x7ff13aebae8
                      p2: 'pin address'=0x7ff13b78178
                      p3: '100*mode+namespace'=0x130ce00010003
            time in wait: 1 min 9 sec
           timeout after: 13 min 50 sec
                 wait id: 29
                blocking: 1 session
            wait history:
              * time between current wait and wait #1: 0.000282 sec
              1.       event: 'PGA memory operation'
                 time waited: 0.000006 sec
                     wait id: 28               p1: ''=0x10000
                                               p2: ''=0x1
              * time between wait #1 and #2: 0.000477 sec
              2.       event: 'SQL*Net message from client'
                 time waited: 16.107334 sec
                     wait id: 27               p1: 'driver id'=0x42455100
                                               p2: '#bytes'=0x1
              * time between wait #2 and #3: 0.000007 sec
              3.       event: 'SQL*Net message to client'
                 time waited: 0.000001 sec
                     wait id: 26               p1: 'driver id'=0x42455100
                                               p2: '#bytes'=0x1
    }
    and is blocked by
 => Oracle session identified by:
    {
                instance: 1 (oprod.oprod)
                   os id: 10480
              process id: 55, ORACLE.EXE (SHAD)
              session id: 385
        session serial #: 46652
    }
alter system kill session '385,46652' immediate;
    which is waiting for 'PL/SQL lock timer' with wait info:
    {
                      p1: 'duration'=0x0
            time in wait: 1 min 12 sec
           timeout after: 4998 min 47 sec
                 wait id: 186
                blocking: 2 sessions
            wait history:
              * time between current wait and wait #1: 0.002311 sec
              1.       event: 'db file sequential read'
                 time waited: 0.002757 sec
                     wait id: 185              p1: 'file#'=0x1
                                               p2: 'block#'=0x18598
                                               p3: 'blocks'=0x1
              * time between wait #1 and #2: 0.001505 sec
              2.       event: 'SQL*Net message from client'
                 time waited: 7.702528 sec
                     wait id: 184              p1: 'driver id'=0x42455100
                                               p2: '#bytes'=0x1
              * time between wait #2 and #3: 0.002764 sec
              3.       event: 'SQL*Net message to client'
                 time waited: 0.000001 sec
                     wait id: 183              p1: 'driver id'=0x42455100
                                               p2: '#bytes'=0x1
    }
 
Chain 1 Signature: 'PL/SQL lock timer'<='library cache pin'<='library cache lock'
Chain 1 Signature Hash: 0x38f0a7dd
-------------------------------------------------------------------------------
 
===============================================================================
Extra information that will be dumped at higher levels:
[level  4] :   1 node dumps -- [LEAF] [LEAF_NW] 
[level  5] :   2 node dumps -- [NO_WAIT] [INVOL_WT] [SINGLE_NODE] [NLEAF] [SINGLE_NODE_NW] 
 
State of ALL nodes
([nodenum]/cnode/sid/sess_srno/session/ospid/state/[adjlist]):
[14]/1/15/38764/000007FF0490E748/13020/NLEAF/[384]
[384]/1/385/46652/000007FF044D1F50/10480/LEAF/
[388]/1/389/26175/000007FF044C8870/2880/NLEAF/[14]

*** 2023-12-06T15:52:59.379269+08:00
===============================================================================
END OF HANG ANALYSIS
===============================================================================

*** 2023-12-06T15:52:59.380269+08:00
Oradebug command 'hanganalyze ' console output: 
Hang Analysis in D:\APP\ADMINISTRATOR\VIRTUAL\diag\rdbms\oprod\oprod\trace\oprod_ora_10320.trc
 

6 分析处理

删除源头堵塞会话 

Chain 1 Signature: 'PL/SQL lock timer'<='library cache pin'<='library cache lock'

and is blocked by
 => Oracle session identified by:
    {
                instance: 1 (oprod.oprod)
                   os id: 10480
              process id: 55, ORACLE.EXE (SHAD)
              session id: 385
        session serial #: 46652
    }

    which is waiting for 'PL/SQL lock timer' with wait info:

alter system kill session '385,46652' immediate;

你可能感兴趣的:(ORACLE数据库追踪管理,数据库,学习)