Tuesday, June 19, 2018

How to resolve ORA-4031 and Shared Pool memory errors

ORA-4031 and Shared Pool Duration

We were getting ORA-4031 errors and shared pool size was over 4GB ( in a RAC environment). We DBAs queried v$sgastat to show that there is plenty of free memory in the shared pool. We
researched the issue and found out about a hidden parameter.  we were confused as to how there
can be ORA-4031 errors when the shared pool free memory is few GBs.

Reason for shared pool errors even after the flush: 
Shared pool review:
Shared pool is split in to multiple sub heaps. Each of those sub heaps are divided in to even smaller sub heaps, let’s call it mini-heaps. Permanent chunks will be allocated only from sga heap(N, 0)  and if that mini-heap runs out of space, ORA-4031 will be thrown.

Solution:
Quick resolution was to increase shared pool_size temporarily. But permanent solution was to set a hidden parameter false.
Parameter:_enable_shared_pool_durations

Query to check the hidden parameter  value:

SET PAGESIZE 60
SET LINESIZE 300
COLUMN ksppinm FORMAT A50
COLUMN ksppstvl FORMAT A50

SELECT
ksppinm,
ksppstvl
FROM
x$ksppi a,
x$ksppsv b
WHERE
a.indx=b.indx
AND
substr(ksppinm,1,1) = '_'
and ksppinm like '%enable_shared_pool_durations%'
ORDER BY ksppinm
/

To set the new value :

ALTER SYSTEM SET "_enable_shared_pool_durations"=false SCOPE=SPFILE;

It is a static parameter and would require a DB restart.


No comments:

Post a Comment