今天,客户反馈测试环境的数据库PGA资源不足,报错ORA-04036: 实例使用的 PGA 内存超出 PGA_AGGREGATE_LIMIT;分析是多个W00n进程使用大量PGA-触发了BUG,对应解决办法就是打补丁。(民间办法就是KILL进程、重启数据库),如下为分析过程:
报错信息:
java.sql.SQLException: ORA-04036: 实例使用的 PGA 内存超出 PGA_AGGREGATE_LIMIT at
oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445) at
oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396) at
oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879) at
oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:450) at
oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192) at
oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207) oracle@localhost:/u01/app/oracle/diag/rdbms/cdb1/cdb1/trace$
oerr ora 4036 04036, 00000, "PGA memory used by the instance exceeds PGA_AGGREGATE_LIMIT" //
*Cause: Private memory across the instance exceeded the limit specified // in the PGA_AGGREGATE_LIMIT initialization parameter. The largest //
sessions using Program Global Area (PGA) memory were interrupted //
to get under the limit. // *Action: Increase the PGA_AGGREGATE_LIMIT initialization parameter or reduce
// memory usage. pga_aggregate_limit limit of aggregate PGA memory consumed by the instance
问题分析:
查看总的PGA分布:select sum(pga_alloc_mem)/(1024*1024) "Mbytes allocated", sum(pga_used_mem)/(1024*1024) "Mbytes used" from v$process;
查找占用内存多的进程:使用SQL;
SELECT DECODE(TRUNC(SYSDATE - LOGON_TIME), 0, NULL, TRUNC(SYSDATE - LOGON_TIME) || ' Days' || ' + ') ||
TO_CHAR(TO_DATE(TRUNC(MOD(SYSDATE-LOGON_TIME,1) * 86400), 'SSSSS'), 'HH24:MI:SS') LOGON,
SID, v$session.SERIAL#, v$process.SPID , ROUND(v$process.pga_used_mem/(1024*1024), 2) PGA_MB_USED,
v$session.USERNAME, STATUS, OSUSER, MACHINE, v$session.PROGRAM, MODULE
FROM v$session, v$process
WHERE v$session.paddr = v$process.addr ORDER BY 4 DESC ;
数据库版本为默认的19.3,未安装RU补丁包。分析此进程,是触发了BUG:Bug 30098251 - WNNN PROCCESSES CREATE AN EXCESSIVE NUMBER OF OPEN CURSORS investigated the issue where Wnnn process has high number of open cursors and consuming more memory.
关于此BUG的描述是:
Each Wnnn Background Process is consuming around 140MB of pga ( can be more as well) and holding hundreds of opened
cursors causing memory usage of instance to go high.
The sessions appear to remain open (session state ACTIVE), holding these cursors.
The Wnnn and SMCo processes appear to remain active for weeks at a time, as we can seen by logon time.
解决办法是:
1、民间办法:KILL进程、或者定期重启数据库。
2、官方办法:SOLUTION:
1. Apply Patch 30098251 available for your release and platform
OR
2. Upgrade to below releases where the fix for 30098251 is first included.
20.1.0
19.6.0.0.200114 (Jan 2020) Database Release Update (DB RU)
18.9.0.0.200114 (Jan 2020) Database Release Update (DB RU)
12.2.0.1.200114 (Jan 2020) Database Release Update (DB RU)
12.1.0.2.200114 (Jan 2020) Database Proactive Bundle Patch
12.2.0.1.200114 (Jan 2020) Bundle Patch for Windows Platforms
There is no workaround for this issue.