프린트 하기

내맘대로긍정이 알려주는

Oracle 23ai 신기능
무료 세미나 발표자료

다운로드 trending_flat
2024
10.12
14:00

OS환경 : Oracle Linux 6.8 (64bit)

 

DB 환경 : Oracle Database 11.2.0.4

 

방법 : 오라클 11gR2 특정에러 trace 확인, 에러스택 확인

에러가 발생했을 때 해당 에러 코드가 클라이언트에만 발생하고 db alert log에 발생하지 않은 경우

그리고 클라이언트쪽에 발생한 에러에 대해서 원인을 찾을 수없을 때

해당 에러번호로 trace를 걸어서 에러 발생시 dump가 수집되게끔 할수 있음

이것을 ErrorStack 덤프라고 부름

 

 

클라이언트에서 ORA-01722: invalid number 로 에러를 발생시키고

db에서 덤프가 수집되는지 확인 해봄

 

 

샘플 테이블 생성(col1 컬럼을 number 형으로 해서 테이블 생성)

1
2
3
SQL> create table test1 (col1 number);
 
Table created.

 

 

샘플 데이터 삽입(정상값)

1
2
3
SQL> insert into test1 values('1');
 
1 row created.

숫자는 정상적으로 insert 됨

 

 

샘플 데이터 삽입(비정상값)

1
2
3
4
5
SQL> insert into test1 values ('a');
insert into test1 values ('a')
                          *
ERROR at line 1:
ORA-01722: invalid number

number 형의 컬럼에 문자를 넣으려고 하면 에러가 발생함

 

 

alert log 확인

1
2
$ vi alert.log
(에러 없음)

클라이언트에서 발생한 이런 에러는 alert log에 기록되지 않음

 

 

errorstack dump 설정(ORA-01722 로 dump 설정)

1
2
3
4
예시 alter system set events '에러번호 trace name errorstack level 1, forever';
SQL> alter system set events '1722 trace name errorstack level 1, forever';
 
System altered.

 

 

클라이언트에서 에러 발생하는 sql 실행

1
2
3
4
5
SQL> insert into test1 values ('a');
insert into test1 values ('a')
                          *
ERROR at line 1:
ORA-01722: invalid number

 

 

errorstack dump 비활성화

1
2
3
4
예시 alter system set events '에러번호 trace name context off';
SQL> alter system set events '1722 trace name context off';
 
System altered.

 

 

alert log 확인

1
2
3
4
$ vi alert.log
Tue Nov 07 01:42:55 2023
Errors in file /app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_4778.trc:
ORA-01722: invalid number

ORA-01722의 에러로그가 trace 파일에 남아있음

 

 

해당 trace 파일 확인

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
$ vi orcl_ora_4778.trc
Trace file /app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_4778.trc
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORACLE_HOME = /app/oracle/product/11.2.0/db_1
System name:    Linux
Node name:      oradb
Release:        4.1.12-37.4.1.el6uek.x86_64
Version:        #2 SMP Tue May 17 07:23:38 PDT 2016
Machine:        x86_64
VM name:        VMWare Version: 6
Instance name: orcl
Redo thread mounted by this instance: 1
Oracle process number: 29
Unix process pid: 4778, image: oracle@oradb (TNS V1-V3)
 
 
*** 2023-11-07 01:42:55.912
*** SESSION ID:(37.112023-11-07 01:42:55.912
*** CLIENT ID:() 2023-11-07 01:42:55.912
*** SERVICE NAME:(SYS$USERS) 2023-11-07 01:42:55.912
*** MODULE NAME:(sqlplus@oradb (TNS V1-V3)) 2023-11-07 01:42:55.912
*** ACTION NAME:() 2023-11-07 01:42:55.912
 
dbkedDefDump(): Starting a non-incident diagnostic dump (flags=0x0, level=1, mask=0x0)
----- Error Stack Dump -----
ORA-01722: invalid number
----- Current SQL Statement for this session (sql_id=a1rkpfcur1jsv) -----
insert into test1 values ('a')
 
----- Call Stack Trace -----
calling              call     entry                argument values in hex
location             type     point                (? means dubious value)
-------------------- -------- -------------------- ----------------------------
skdstdst()+41        call     kgdsdst()            000000000 ? 000000000 ?
                                                   7FFD6BE2B4B0 ? 7FFD6BE2B588 ?
                                                   7FFD6BE30030 ? 000000002 ?
ksedst1()+103        call     skdstdst()           000000000 ? 000000000 ?
                                                   7FFD6BE2B4B0 ? 7FFD6BE2B588 ?
                                                   7FFD6BE30030 ? 000000002 ?
ksedst()+39          call     ksedst1()            000000000 ? 000000001 ?
                                                   7FFD6BE2B4B0 ? 7FFD6BE2B588 ?
.
.

 

 

 

이렇게 errorstack 덤프는 그 레벨에 따라 다양한 유용한 정보를 제공 해줌으로써

해당 문제에 대한 원인 분석에 도움을 줄 수 있음

 

 

참고용 trace 파일 전체

orcl_ora_4778.trc
0.26MB

 

 

참조 : 

http://tech.e2sn.com/oracle/troubleshooting/how-to-read-errorstack-output
http://ukja.tistory.com/307
https://web-dev.tistory.com/m/373