时间:2021-01-18 14:45:33 | 栏目:Oracle | 点击:次
现象
tomcat错误日志断断续续报ORA-00903: invalid table name,并无具体SQL与表名,需要排查哪段代码写入了无效表名,
可以通过ORACLE提供的errorstack追踪报错SQL。
由于生产数据无法取出,以下皆为测试环境测试还原生产错误。
errorstack简介
设置errorstack,在发生特定的ORA错误时会记录发生问题的会话,语句以及各个进程的trace文件,
在alert日志中有记录错误记录的trace文件位置,也可以给单独会话开启errorstack,追踪会话报错信息,可以通过
下面两个方法开启:
/* level 0 仅转储错误堆栈
/* level 1 转储错误堆栈和函数调用堆栈
/* level 2 Level 1 + ProcessState
/* level 3 Level 2 + Context area (显示所有cursors,着重显示当前cursor)
(1)alter session/system
alter session/system set events '<error_number> trace name errorstack level 3';
/* error_number为ORA错误后编号。
(2)oradebug
/* 使用oradebug需要用户具有sysdba权限
SQL> oradebug setospid/setmypid/setorapid <pid>;
SQL> oradebug dump errorstack 3
可以通过下面方法查看当前系统开启errorstack状态:
SQL> set serveroutput on
SQL> oradebug setmypid
SQL> oradebug eventdump session/system;
追踪
SQL> alter system set events '903 trace name errorstack level 3';
alter日志:
Tue Jun 09 14:23:44 2020
OS Pid: 10855 executed alter system set events '903 trace name errorstack level 3'
追踪结果
alert日志信息:
alert日志信息:
Tue Jun 09 14:28:04 2020
Errors in file /u01/app/oracle/diag/rdbms/honor/honor1/trace/honor1_ora_7205.trc:
ORA-00903: 表名无效
Tue Jun 09 14:28:06 2020
Dumping diagnostic data in directory=[cdmp_20200609142806], requested by (instance=1, osid=7205), summary=[abnormal process termination].
查看对应trc追踪文件:
*** 2020-06-09 14:28:04.303
*** SESSION ID:(26.661) 2020-06-09 14:28:04.303
*** CLIENT ID:() 2020-06-09 14:28:04.303
*** SERVICE NAME:(honor) 2020-06-09 14:28:04.303
*** MODULE NAME:(SQL*Plus) 2020-06-09 14:28:04.303
*** ACTION NAME:() 2020-06-09 14:28:04.303
dbkedDefDump(): Starting a non-incident diagnostic dump (flags=0x0, level=3, mask=0x0)
----- Error Stack Dump -----
ORA-00903: 表å<90><8d>æ<97> æ<95><88>
----- Current SQL Statement for this session (sql_id=0vaqwchf1y3fq) -----
insert into null values(1)
找到具体sql,拿给开发人员,修改相关逻辑,错误修复。
关闭errorstack
SQL > alter system set events '903 trace name errorstack off';
总结