zoukankan      html  css  js  c++  java
  • 转 Trace a specific ORA- error

    #感谢Vincent Fenoll,

    Trace a specific ORA- error

    How to trace a specific ORA- error that is raised and can be reproduced?
    We want to find the complete Oracle stack to understand the origin of this error.

    For example, I want to understand why datapump expdp/impdp raises:
    ORA-01422: exact fetch returns more than requested number of rows

    This time, the alert file is not very helpful.

    To determine the root cause, event 1422 can be set as follows:

    connect /as sysdba 
    alter system set events '1422 trace name ERRORSTACK level 3'; 

    […reproduce the issue…]

    The event can be turned off again using:

    connect /as sysdba

    alter system set events '1422 trace name ERRORSTACK off';

    In the event 1422 trace file, below sql query was causing error.

    *** ACTION NAME:(Select sys_context into variable) 2017-01-27 14:15:24.257
    *** MODULE NAME:(Trigger DDL_AUDIT) 2017-01-27 14:15:24.257
    *** SERVICE NAME:(SYS$USERS) 2017-01-27 14:15:24.257
    *** SESSION ID:(3265.22843) 2017-01-27 14:15:24.257
    *** 2017-01-27 14:15:24.257
    ksedmp: internal or fatal error
    ORA-01422: exact fetch returns more than requested number of rows
    Current SQL statement for this session:
    SELECT UPPER(OSUSER), PROGRAM, MODULE, CLIENT_INFO FROM V$SESSION WHERE AUDSID = SYS_CONTEXT(‘userenv’, ‘SESSIONID’)

    Of course, it’s easier to locate the target module if you have already instrumented your code with DBMS_APPLICATION_INFO.SET_MODULE and DBMS_APPLICATION_INFO.SET_ACTION;

    In this case, the problem was due to SYS_CONTEXT(‘USERENV’,’SESSIONID’) returning 2 rows causing the ORA-01422 and subsequent datapump failure.

    The workaround of this specific problem is to disable the Trigger DDL_AUDIT.
    A solution is to modify the cursor or the statement in the trigger to retreive just one row, for example:
    SELECT UPPER(OSUSER), PROGRAM, MODULE, CLIENT_INFO FROM V$SESSION
    WHERE AUDSID = SYS_CONTEXT(‘userenv’, ‘SESSIONID’) and rownum=1;
    Another solution is to trap error with an excveption clause.

     
    Author: Vincent Fenoll, Oracle DBA Montreal

    Trace a specific ORA- error

    How to trace a specific ORA- error that is raised and can be reproduced?
    We want to find the complete Oracle stack to understand the origin of this error.

    For example, I want to understand why datapump expdp/impdp raises:
    ORA-01422: exact fetch returns more than requested number of rows

    This time, the alert file is not very helpful.

    To determine the root cause, event 1422 can be set as follows:

    connect /as sysdba 
    alter system set events '1422 trace name ERRORSTACK level 3'; 

    […reproduce the issue…]

    The event can be turned off again using:

    connect /as sysdba

    alter system set events '1422 trace name ERRORSTACK off';

    In the event 1422 trace file, below sql query was causing error.

    *** ACTION NAME:(Select sys_context into variable) 2017-01-27 14:15:24.257
    *** MODULE NAME:(Trigger DDL_AUDIT) 2017-01-27 14:15:24.257
    *** SERVICE NAME:(SYS$USERS) 2017-01-27 14:15:24.257
    *** SESSION ID:(3265.22843) 2017-01-27 14:15:24.257
    *** 2017-01-27 14:15:24.257
    ksedmp: internal or fatal error
    ORA-01422: exact fetch returns more than requested number of rows
    Current SQL statement for this session:
    SELECT UPPER(OSUSER), PROGRAM, MODULE, CLIENT_INFO FROM V$SESSION WHERE AUDSID = SYS_CONTEXT(‘userenv’, ‘SESSIONID’)

    Of course, it’s easier to locate the target module if you have already instrumented your code with DBMS_APPLICATION_INFO.SET_MODULE and DBMS_APPLICATION_INFO.SET_ACTION;

    In this case, the problem was due to SYS_CONTEXT(‘USERENV’,’SESSIONID’) returning 2 rows causing the ORA-01422 and subsequent datapump failure.

    The workaround of this specific problem is to disable the Trigger DDL_AUDIT.
    A solution is to modify the cursor or the statement in the trigger to retreive just one row, for example:
    SELECT UPPER(OSUSER), PROGRAM, MODULE, CLIENT_INFO FROM V$SESSION
    WHERE AUDSID = SYS_CONTEXT(‘userenv’, ‘SESSIONID’) and rownum=1;
    Another solution is to trap error with an excveption clause.

     
    Author: Vincent Fenoll, Oracle DBA Montreal

  • 相关阅读:
    sql server 分组,取每组的前几行数据
    安装vim的ycm
    Linux下管道重定向使用以及Shell编程(操作系统)
    VirtualBox安装及Linux基本操作(操作系统实验一)
    创建表并查看表(数据库实验一)
    SQL SERVER安装(2008)
    ADT图及图的实现及图的应用
    并查集实现及使用
    堆及堆的应用/单调队列/堆排序
    AVL树/线索二叉树
  • 原文地址:https://www.cnblogs.com/feiyun8616/p/14139753.html
Copyright © 2011-2022 走看看