ORA-04031錯誤分析
本文作者:husthxd
ORACLE Bug導致的ORA-04031:
BUG | Description | Workaround | Fixed |
<> | ORA-4031 / SGA memory leak of PERMANENT memory occurs for buffer handles. | _db_handles_cached = 0 | 8172, 901 |
<> | ORA-4031 due to leak / cache buffer chain contention from AND-EQUAL access | Not available | 8171, 901 |
Bug:1318267 | INSERT AS SELECT statements may not be shared when they should be if TIMED_STATISTICS. It can lead to ORA-4031 | _SQLEXEC_PROGRESSION_COST=0 | 8171, 8200 |
Bug:1193003 | Cursors may not be shared in 8.1 when they should be | Not available | 8162, 8170, 901 |
<> | ORA-4031/excessive "miscellaneous" | None-> This is known to affect the XML parser. | 8174, 9013, 9201 |
<> | Several number of BUGs related |
| 9205 |
2.編譯java程式碼時出現ORA-4031錯誤
出現ORA-04031: unable to allocate bytes of shared memory ("shared pool","unknown object","joxlod: init h", "JOX: ioc_allocate_pal")增大JAVA_POOL_SIZE到一個合適的值即可(一般100m足夠)。
3.LARGE_POOL_SIZE過小導致ORA-04031: unable to allocate XXXX bytes of shared memory ("large pool","unknown object","session heap","frame"),增大LARGE_POOL_SIZE即可。
4.ORA-04031錯誤的高階分析
SESSION級:
SQL> alter session set events '4031 trace name errorstack level 3';
SQL> alter session set events '4031 trace name HEAPDUMP level 3';
INSTANCE級:
初始化引數中設定
event = "4031 trace name errorstack level 3"
event = "4031 trace name HEAPDUMP level 3"
5.調整SHARED_POOL_SIZE以避免ORA-04031錯誤。
1)使用DBMS_SHARED_POOL.KEEP把經常執行的package keep到共享池中。
2)調整引數SHARED_POOL_RESERVED_SIZE大致為SHARED_POOL_SIZE的10%;但如果SHARED_POOL_SIZE很大的話可以適當調小該引數;如果 SHARED_POOL_RESERVED_MIN_ALLOC低於default值的話,適當調大該引數,因為SHARED_POOL_RESERVED_MIN_ALLOC較低會導致更多共享語句從SHARED_POOL_RESERVED_SIZE所指定的區域中分配記憶體。
3)一些用於定位問題的指令碼
A.定位應該使用繫結變數的sql語句
SELECT substr(sql_text,1,40) "SQL",
count(*) ,
sum(executions) "TotExecs"
FROM v$sqlarea
WHERE executions < 5
GROUP BY substr(sql_text,1,40)
HAVING count(*) > 30
ORDER BY 2
/
40表示sql語句的前40個字元是一樣的,5表示執行次數小於5次,30表示在shared_pool_size中出現不下30次。
B.以sys使用者執行以下語句
SELECT * FROM X$KSMLRU WHERE ksmlrsiz > 0
/
X$KSMLRU 表顯示那段記憶體的分配導致大多數的chunks從共享記憶體中aged out。
C.獲得library cache hit
SELECT SUM(PINS) "EXECUTIONS",
SUM(RELOADS) "CACHE MISSES WHILE EXECUTING"
FROM V$LIBRARYCACHE
/
D.顯示在free list中可用的chunks
select '0 (<140)' BUCKET, KSMCHCLS, 10*trunc(KSMCHSIZ/10) "From",
count(*) "Count" , max(KSMCHSIZ) "Biggest",
trunc(avg(KSMCHSIZ)) "AvgSize", trunc(sum(KSMCHSIZ)) "Total"
from x$ksmsp
where KSMCHSIZ<140
and KSMCHCLS='free'
group by KSMCHCLS, 10*trunc(KSMCHSIZ/10)
UNION ALL
select '1 (140-267)' BUCKET, KSMCHCLS, 20*trunc(KSMCHSIZ/20) ,
count(*) , max(KSMCHSIZ) ,
trunc(avg(KSMCHSIZ)) "AvgSize", trunc(sum(KSMCHSIZ)) "Total"
from x$ksmsp
where KSMCHSIZ between 140 and 267
and KSMCHCLS='free'
group by KSMCHCLS, 20*trunc(KSMCHSIZ/20)
UNION ALL
select '2 (268-523)' BUCKET, KSMCHCLS, 50*trunc(KSMCHSIZ/50) ,
count(*) , max(KSMCHSIZ) ,
trunc(avg(KSMCHSIZ)) "AvgSize", trunc(sum(KSMCHSIZ)) "Total"
from x$ksmsp
where KSMCHSIZ between 268 and 523
and KSMCHCLS='free'
group by KSMCHCLS, 50*trunc(KSMCHSIZ/50)
UNION ALL
select '3-5 (524-4107)' BUCKET, KSMCHCLS, 500*trunc(KSMCHSIZ/500) ,
count(*) , max(KSMCHSIZ) ,
trunc(avg(KSMCHSIZ)) "AvgSize", trunc(sum(KSMCHSIZ)) "Total"
from x$ksmsp
where KSMCHSIZ between 524 and 4107
and KSMCHCLS='free'
group by KSMCHCLS, 500*trunc(KSMCHSIZ/500)
UNION ALL
select '6+ (4108+)' BUCKET, KSMCHCLS, 1000*trunc(KSMCHSIZ/1000) ,
count(*) , max(KSMCHSIZ) ,
trunc(avg(KSMCHSIZ)) "AvgSize", trunc(sum(KSMCHSIZ)) "Total"
from x$ksmsp
where KSMCHSIZ >= 4108
and KSMCHCLS='free'
group by KSMCHCLS, 1000*trunc(KSMCHSIZ/1000)
/
E.檢查高版本計數的sql語句
SELECT address, hash_value,
version_count ,
users_opening ,
users_executing,
substr(sql_text,1,40) "SQL"
FROM v$sqlarea
WHERE version_count > 10
/
F.檢查使用了多量的shared memory的sql語句
SELECT substr(sql_text,1,40) "Stmt", count(*),
sum(sharable_mem) "Mem",
sum(users_opening) "Open",
sum(executions) "Exec"
FROM v$sql
GROUP BY substr(sql_text,1,40)
HAVING sum(sharable_mem) > memsize
/
參考文件:
【metalink 】Diagnosing and Resolving Error ORA-04031
【metalink 】Understanding and Tuning the Shared Pool
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/166555/viewspace-780341/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ORA-04031錯誤分析和解決
- SHARED POOL ORA-04031錯誤分析
- ORA-04031錯誤導致當機案例分析
- ORA-04031錯誤詳解
- 案例分析:ora-04031與ora-04030錯誤分析與解決
- ORA-04031錯誤的處理
- 如何解決ORA-04031 錯誤(轉)
- 如何解決ORA-04031 錯誤(zt)
- 診斷並解決ORA-04031 錯誤
- 【EXPDP】使用EXPDP備份資料時ORA-39125、ORA-04031錯誤原因分析與排查
- ORA-12853和ORA-04031 large pool 不足錯誤解決
- Oracle 11g RAC操作DBCA期間報ORA-04031錯誤Oracle
- buffer cache 和shared pool詳解 診斷和解決ORA-04031 錯誤
- net 日誌分析錯誤
- web拼圖錯誤分析Web
- ORA-25138錯誤分析
- java.exe出錯錯誤分析 (轉)Java
- 【問題處理】dbca建庫過程中報 ORA-04031錯誤的排查
- [zt] ORA-04031故障分析處理
- ORA-00600錯誤分析
- ORA-04021錯誤分析
- ORA-07445錯誤分析
- ORA-00942錯誤分析
- 在 11.2.0.4 執行 utlrp.sql 出現 ORA-04031 錯誤解決方法SQL
- 通過錯誤堆疊資訊和原始碼分析錯誤來源原始碼
- 轉貼:ORA-04031故障分析處理
- ORA-04031 的原因分析解決方法
- [20190104]sga_target 的設定和ORA-04031錯誤.txt
- [java基礎]之基本錯誤分析Java
- GoldenGate 常見錯誤分析(二)Go
- 產品需求分析中常見錯誤?
- ORA-27100錯誤分析
- ORA-01950錯誤分析
- ORA-03113錯誤分析
- ORA-12571錯誤分析
- ORA-01691錯誤分析
- ORA-31600錯誤分析
- ORA-00205錯誤分析