使用ErrorStack進行錯誤跟蹤及診斷

記錄每一次錯誤發表於2018-12-19

使用ErrorStack進行錯誤跟蹤及診斷

在使用

資料庫的過程中,可能會遇到各種各樣的錯誤或異常,很多異常的提示並不具體,我們有必要了解一下 跟蹤方式。


提供的一種對於錯誤堆疊進行跟蹤的方法,透過設定跟蹤可以將一些錯誤的後臺資訊詳盡地轉儲出來,寫入跟蹤檔案,對於錯誤的研究與診斷非常有效。


ErrorStack 4 2 Level1 + ProcessState

(顯示所有 ,著重顯示當前


可以在例項級或會話級別設定,也可以在引數檔案中設定,這個設定僅當某個特定的錯誤出現時才被觸發,如設定 事件的跟蹤:

一個客戶曾經出現如下 錯誤,提示資料的精度超過允許值,是後臺 排程的任務:

Errors in file /admin/erpdb/bdump/erpdb1_j000_447020.trc:
ORA-01438: value larger than specified precision allowed for this column
ORA-06512: at line 1


SQL ErrorStack SQL alter system set events='1438 trace name errorstack forever,level 3';


alter system set events='1438 trace name errorstack off';


Oracle 10g Mon Jul 13 10:48:392009
Mon Jul 13 10:56:06 2009
ORA-01438: value larger than specified precision allowed for this column
Trace dumping is performing id=[cdmp_20090713105608]
OS Pid: 541528 executed alter system set events '1438 trace name Errorstackoff'


SQL SQL SQL Number ***SESSION ID:(857.16304) 2009-07-13 10:56:06.429
ksedmp: internal or fatal error
Current SQL statement for this session:
----- PL/SQL Call Stack -----
handle number name
700000336a1a070 236 procedure ERP.PROC_AUTOBATPROC
700000342eb7c20 1 anonymous block


可以很容易地測試這一功能的使用,比如使用如下程式碼中的測試過程:

SQL> connect eygle/eygle
Table created.
insert into t values(a,1)
ERROR at line 1:
SQL> alter system set events '984 trace name errorstack off';


Mon Jul 13 22:55:592009
Mon Jul 13 22:59:12 2009
ORA-00984: column not allowed here
OS Pid: 2431 executed alter system set events '984 trace name errorstack off'


insert *** 2009-07-13 22:59:12.928
ORA-00984: column not allowed here
insert into t values(a,1)
calling call entry argument values in hex
-------------------- -------- -------------------- ----------------------------



以下引用在ITPUB上的一個討論,是使用ErrorStack跟蹤解決問題的典型案例(原文連結指向ITPUB)

Import: Release 10.2.0.1.0 - Production on Tue Mar 18 14:19:49 2008

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production

Export file created by EXPORT:V10.02.01 via conventional path

. importing DBA_MGR's objects into DBA_MGR

IMP-00058: ORACLE error 1438 encountered

IMP-00028: partial import of previous table rolled back: 20501 rows rolled back

System altered

然後重新執行IMP;

2、檢視UDUMP下日誌,如下:

/opt/oracle/admin/orcl/udump/orcl_ora_32355.trc

With the Partitioning, OLAP and Data Mining options

System name:Linux

Release:2.6.9-22.ELsmp

Machine:x86_64

Redo thread mounted by this instance: 1

Unix process pid: 32355, image: oracle@zhx25.cccc.com (TNS V1-V3)


*** SESSION ID135.949) 2008-03-18 17:11:02.014

ksedmp: internal or fatal error

Current SQL statement for this session:

("PRTNO", "SEQNO", "SEQDESC", "PRTEFLAG", "SEQCC", "SEQNXTNO", "SEQDEPT", "WKCCODE", "WKCALTCODE", "SEQSETHR", "LAB_SEQSETHR", "SEQRUNHR", "LAB_SEQRUNHR", "SEQQUEHR", "LAB_SEQQUEHR", "SEQTRANHR", "LAB_SEQTRANHR", "SEQNOQLTRAT", "SEQCHGDAT", "SEQCHGRSN", "SEQCHGCTLR", "MACHCODE", "MACHALTCODE", "RESCODE", "KEYSEQ", "SEQCRYLOT", "INITOVERRATE", "COMWORK", "SEQLOTFLAG", "SEQEFDAT", "SEQIEFDAT", "SEQEFLOTNO", "SEQIEFLOTNO", "SEQECONO", "PRTSEQCST", "SEQSELFCST", "INVYORN", "SEQQTY", "SEQNOTE", "NOPRTAVELZ", "OUTSEQFLAG", "WXCST", "SEQGSCHGCTLR", "SEQGSCHGDAT", "SEQSHCTL", "SEQSHDAT", "SEQSHSIGN", "PRICE", "ACCNO", "ROUSTAT", "FIXMFLAG", "BANCL"   (:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19, :20, :21, :22, :23, :24, :25, :26, :27, :28, :29, :30, :31, :32, :33, :34, :35, :36, :37, :38, :39, :40, :41, :42, :43, :44, :45, :46, :47, :48, :49, :50, :51, :52)

calling

entry

location

point

…………


Offsi = 48, Offsi = 1440


Bind Twotask Scalar Sql In (may be out) Copy 


Offsi = 48, Offsi = 1472


Bind Twotask Scalar Sql In (may be out) Copy 


Offsi = 48, Offsi = 1504


Bind Twotask Scalar Sql In (may be out) Copy 


Offsi = 48, Offsi = 1536


Bind Twotask Scalar Sql In (may be out) Copy 


Offsi = 48, Offsi = 1568


Bind Twotask Scalar Sql In (may be out) Copy 


Offsi = 48, Offsi = 1600


Bind Twotask Scalar Sql In (may be out) Copy 


Offsi = 48, Offsi = 1632

Bind#0

oacflg=03 fl2=1000010 frm=01 csi=852 siz=3344 off=0


bln=32

flg=05


<span "="" style="margin: 0px; padding: 0px; max-width: 100%; box-sizing: border-box !important;">value="?


oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00

kxsbbbfp=2a974dc3b8

value=###

Dump of memory from 0x0000002A974CDE88 to 0x0000002A974CDE9E

2A974CDE90 C9BBC6C8 52024D01 30310248 00003304[.....M.RH.10.3..]


oacdty=01 mxl=32(30) mxlc=00 mal=00 scl=00 pre=00

kxsbbbfp=2a974dc3d0

avl=00

Bind#3

oacflg=03 fl2=1000010 frm=01 csi=852 siz=0 off=88

bln=32

flg=01


…………

從跟蹤檔案可以看到,問題是系統認為地址為2A974CDE88的數值非法,在匯入會提示ORA-1438錯誤。

3、找到DMP中相關資料

用winhex開啟dmp檔案,搜尋十六進位制串“2E313133 02C10604 C8C6BBC9 014D0252 48023130 0433F3FF”(對trace檔案中的值要進行順序調整)


5、對資料庫相關資料項的型別進行調整

把資料項的型別由number(*)改為number(38);

6、重新進行資料匯入

[oracle@zhx25 ~]$ imp system/ceshi fromuser=dba_mgr touser=dba_mgr tables=t_routdef ignore=y file=1.dmp


Copyright (c) 1982, 2005, Oracle. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production

Export file created by EXPORT:V10.02.01 via conventional path

. importing DBA_MGR's objects into DBA_MGR

"T_ROUTDEF"


本文透過介紹ErrorStack的應用,將這一常用的診斷工具介紹給大家,作為DBA,在遇到複雜問題時,透過這些手段深入分析,不僅有助於問題的解決,還將完善自己的知識體系,祝大家學習能夠不斷進步、深入。


本文是轉載文章

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31547066/viewspace-2285739/,如需轉載,請註明出處,否則將追究法律責任。

相關文章