小知識:使用errorstack定位特定問題

AlfredZhao發表於2023-04-26

有客戶遇到ORA-2289的報錯,同事協助去現場排查,我幫著遠端共同check下。
客戶只是應用端報出的錯誤,為了進一步定位,服務端需要開errorstack協助定位具體問題。
下面就以這個ORA-2289為例,示範下errorstack的使用方法。

--開啟errorstack
alter system set events '2289 trace name errorstack level 3';

--關閉errorstack
alter system set events '2289 trace name errorstack off';

開啟errorstack期間,模擬一個會話發生了ORA-02289的報錯:

[oracle@bogon trace]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Apr 26 22:00:21 2023
Version 19.16.0.0.0

Copyright (c) 1982, 2022, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.16.0.0.0

SQL> select s2.nextval from dual;
select s2.nextval from dual
       *
ERROR at line 1:
ORA-02289: sequence does not exist


SQL> exit

在alert告警日誌可以看到提示:

2023-04-26T22:00:27.300427+08:00
Errors in file /u01/app/oracle/diag/rdbms/demo/demo/trace/demo_ora_3435.trc:
ORA-02289: sequence does not exist

進而在trc檔案中進一步查詢具體報錯的SQL資訊等:

[oracle@bogon trace]$ vi demo_ora_3435.trc 
...
   17 *** 2023-04-26T22:00:27.300081+08:00 (CDB$ROOT(1))
   18 *** SESSION ID:(2548.56891) 2023-04-26T22:00:27.300150+08:00
   19 *** CLIENT ID:() 2023-04-26T22:00:27.300158+08:00
   20 *** SERVICE NAME:(SYS$USERS) 2023-04-26T22:00:27.300164+08:00
   21 *** MODULE NAME:(sqlplus@bogon (TNS V1-V3)) 2023-04-26T22:00:27.300170+08:00
   22 *** ACTION NAME:() 2023-04-26T22:00:27.300177+08:00
   23 *** CLIENT DRIVER:(SQL*PLUS) 2023-04-26T22:00:27.300182+08:00
   24 *** CONTAINER ID:(1) 2023-04-26T22:00:27.300189+08:00
   25 
   26 dbkedDefDump(): Starting a non-incident diagnostic dump (flags=0x0, level=3, mask=0x0)
   27 ----- Error Stack Dump -----
   28 <error barrier> at 0x7ffed8393280 placed dbkda.c@298
   29 ORA-02289: sequence does not exist
   30 ----- Current SQL Statement for this session (sql_id=c6bu1kcbt5z3f) -----
   31 select s2.nextval from dual
   32 
   33 ----- Call Stack Trace -----
   34 calling              call     entry                argument values in hex
   35 location             type     point                (? means dubious value)
   36 -------------------- -------- -------------------- ----------------------------
   37 ksedst1()+95         call     kgdsdst()            7FFED83926E0 000000002
...

我這裡模擬是直接查詢了不存在的序列,但是報這個錯誤其實未必是資料庫問題,可以在MOS多搜尋下相關案例,也有程式配置問題導致的情況。

相關文章