PGA_AGGREGATE_LIMIT參數

PGA_AGGREGATE_LIMIT參數由12.1引入,用於對pga進行硬限制。如果超過了該值,報ora-04036錯誤:


[oracle@prodb ~]$ 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.


默認值如下:

If MEMORY_TARGET is set, then PGA_AGGREGATE_LIMIT defaults to the MEMORY_MAX_TARGET value.

If MEMORY_TARGET is not set, then PGA_AGGREGATE_LIMIT defaults to 200% of PGA_AGGREGATE_TARGET.

If MEMORY_TARGET is not set, and PGA_AGGREGATE_TARGET is explicitly set to 0, then the value of PGA_AGGREGATE_LIMIT is set to 90% of the physical memory size minus the total SGA size.

In all cases, the default PGA_AGGREGATE_LIMIT is at least 2GB and at least 3MB times the PROCESSES parameter (and at least 5MB times the PROCESSES parameter for an Oracle RAC instance).

For a PDB, the default value is the same as the CDB's default value.

引用自:https://docs.oracle.com/en/database/oracle/oracle-database/19/refrn/PGA_AGGREGATE_LIMIT.html#GUID-E364D0E5-19F2-4081-B55E-131DF09CFDB3


使用數據庫參數 PGA_AGGREGATE_LIMIT 限制進程大小 (文檔 ID 1602891.1)

文檔內容

用途

問題和答案

參考

適用於:

Oracle Database - Enterprise Edition - 版本 12.1.0.1 和更高版本

Oracle Database Cloud Schema Service - 版本 N/A 和更高版本

Oracle Database Exadata Cloud Machine - 版本 N/A 和更高版本

Oracle Database Exadata Express Cloud Service - 版本 N/A 和更高版本

Oracle Cloud Infrastructure - Database Service - 版本 N/A 和更高版本

本文檔所含信息適用於所有平臺

用途

本文介紹如何使用新參數 PGA_AGGREGATE_LIMIT 限制數據庫進程可以增長到的最大大小。


問題和答案

 


在自動化 PGA 內存管理模式下,Oracle 數據庫通過動態控制分配到工作區的 PGA 內存量來嘗試遵從 PGA_AGGREGATE_TARGET 值。但是,有時因爲以下原因,PGA 內存使用量可能會超過 PGA_AGGREGATE_TARGET 設置:


PGA_AGGREGATE_TARGET 設置起到的是目標的作用,而非限制。


PGA_AGGREGATE_TARGET 僅控制可優化部分內存的分配。


使用大量 PGA 可能會導致高交換率。出現這種情況時,系統可能會無法響應,並且不穩定。這種時候需要考慮使用 PGA_AGGREGATE_LIMIT 初始化參數限制整體 PGA 使用量。


 


12c 引入了新的參數 PGA_AGGREGATE_LIMIT 以允許數據庫管理員限制 pga 內存使用總量。


使用 PGA_AGGREGATE_LIMIT初始化參數可以爲 PGA 內存使用量指定硬性限制。如果超過了 PGA_AGGREGATE_LIMIT 值,則 Oracle 數據庫按照以下順序,中斷或者終止使用了最多不可優化 PGA 內存的會話或進程:


中止使用了最多不可優化 PGA 內存的會話調用。


如果 PGA 內存使用量仍超過 PGA_AGGREGATE_LIMIT,則終止使用了最多不可優化 PGA 內存的會話和進程。


使用最多不可優化內存會話的調用將被中止。並行查詢將被視爲一個單元。如果 PGA 內存使用總量仍超過限制,則將終止使用最多不可優化內存的會話。


不會對除作業隊列進程之外的 SYS 進程和後臺進程執行這一部分中所述的任何操作。取而代之的操作是,如果它們使用了最多不可優化內存,則會定期將其 PGA 使用量的簡短摘要寫入到跟蹤文件中。


 

PGA_AGGREGATE_LIMIT 初始化參數動態設置爲 PGA 內存的實例範圍硬性限制。由於該參數根據內存情況的變化做出響應,您無需顯式設置參數值。默認情況下,PGA_AGGREGATE_LIMIT被設置爲:


在Oracle 12.1版本: PGA_AGGREGATE_LIMIT默認爲如下值中的最大者:


2 GB

200% 的 PGA_AGGREGATE_TARGET

(PROCESSES 初始化參數設置值)* 3 MB

該參數不會超過物理內存大小減去總 SGA 大小的 120%。


在Oracle 12.2版本: PGA_AGGREGATE_LIMIT的默認值爲:


* 如果設置了MEMORY_TARGET, 那麼PGA_AGGREGATE_LIMIT默認值爲MEMORY_MAX_TARGET的值.

* 如果MEMORY_TARGET沒有設置, 那麼PGA_AGGREGATE_LIMIT默認值爲 200%的PGA_AGGREGATE_TARGET值.

* 如果MEMORY_TARGET沒有設置, 並且PGA_AGGREGATE_TARGET被顯式的設置爲0, 那麼PGA_AGGREGATE_LIMIT的默認值爲90%的物理內存減去SGA的大小.

在以上所有情況中,默認的PGA_AGGREGATE_LIMIT至少是2GB 並且至少是數據庫參數PROCESSES乘以3MB的大小.


注意: 在 12.1 或者 12.2中,如果指定PGA_AGGREGATE_LIMIT的值爲0,則表示實例所使用的 PGA 內存總量沒有限制。


PGA_AGGREGATE_LIMIT 初始化參數可以動態設置;並不需要數據庫重新啓動。可以設置 PGA_AGGREGATE_LIMIT 的值,不論是否使用了自動內存管理。


後臺進程 CKPT 每三秒檢查一次內存用量是否超過了 PGA_AGGREGATE_LIMIT 初始化參數的值。如果達到或超過了限制,則此進程中斷使用最多不可優化 PGA 內存的會話調用。如果這些會話仍沒有釋放足夠內存,則終止它們。


請注意,由於 pga 值僅每三秒檢查一次,因此 pga 內存有可能超過 PGA_AGGREGATE_LIMIT。此外,如果在此期間該 pga 值減少到限制之下,則將不會捕獲在這三秒間隔內超過限制的情況。如果進程在三秒的間隔內快速分配然後釋放內存,則可能會出現這種情況。


示例:


如下的信息會被寫入到CKPT trace 文件,


PGA LIMIT: pid 317111 is ineligible for an ORA-4036 interrupt

System processes and most background processes cannot receive ORA-4036

interrupts. When they are contributing to the instance exceeding

PGA_AGGREGATE_LIMIT, they will periodically dump their PGA usage.

PGA LIMIT: pid 317124 is a top contributor to going over PGA_AGGREGATE_LIMIT

PGA LIMIT: pid 317124 is ineligible for an ORA-4036 interrupt

PGA LIMIT: pid 317120 is a top contributor to going over PGA_AGGREGATE_LIMIT

PGA LIMIT: pid 317120 is ineligible for an ORA-4036 interrupt


 


如果達到了 PGA_AGGREGATE_LIMIT 值,則將報告如下錯誤。


ORA-04036: 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.

示例:


 此示例將展示使用 pl/sql 填充內存中數組可以超過 pga_aggregate_limit 的值。


 


首先請查看當前 pga_aggregate_target。由於 pl/sql 內存區不是 pga 目標控制的可優化區域,進程 pga 將超過此值。


-- V$PGASTAT 的 PGA 統計信息:

-- 顯示自實例啓動以來分配的最大 pga 總量


select name, ROUND(value/1024/1024) as Mbytes from v$pgastat

where name in ('maximum PGA allocated','aggregate PGA target parameter','aggregate PGA auto target');

NAME                         Mbytes

---------------------- ------------

aggregate PGA target p          208

arameter


aggregate PGA auto tar          138

get


maximum PGA allocated           119


 


 請注意 pga_aggregate_limit 顯式設置爲 512M。


select con_id, name as Parameter, value/1024/1024 as Mbytes from V$SYSTEM_PARAMETER

where name in ('pga_aggregate_target','memory_target','memory_max_target','sga_max_size','sga_target','pga_aggregate_limit','processes')

order by name;

CON_ID PARAMETER                            Mbytes

------ ------------------------------ ------------

     0 memory_max_target                       600

     0 memory_target                           600

     0 pga_aggregate_limit                     512

     0 pga_aggregate_target                      0

     0 processes                                 0

     0 sga_max_size                            600

     0 sga_target                                0



 


運行這個過程的會話收到此錯誤:


 


ERROR at line 1:

ORA-04036: PGA memory used by the instance exceeds PGA_AGGREGATE_LIMIT

 


針對 V$PROCESS 的查詢顯示進程在 ckpt進程捕獲到這種情況並中止其對內存的調用之前,在 3 秒時間內增長到 2.5G 大小。


 


[Insert code here]

CON_ID OSpid     Orapid Sess id Serial# Status      PGA alloc     PGA used      PGA Max PNAME oracleuser   OS user      Program

------ -------- ------- ------- ------- -------- ------------ ------------ ------------ ----- ------------ ------------ ------------------------

     4 5349          33     258      41 INACTIVE            3            2        2,536       SYSTEM       oracle       [email protected]

                                                                                                                        omain (TNS V1-V3)



 


 


alert.log 顯示以下錯誤。


 


Errors in file /u01/app/oracle/diag/rdbms/cdb1/cdb1/trace/cdb1_ora_5349.trc  (incident=79479):

ORA-04036: PGA memory used by the instance exceeds PGA_AGGREGATE_LIMIT

Incident details in: /u01/app/oracle/diag/rdbms/cdb1/cdb1/incident/incdir_79479/cdb1_ora_5349_i79479.trc

Dumping diagnostic data in directory=[cdmp_20130128072143], requested by (instance=1, osid=5349), summary=[incident=79479].


 


進程的跟蹤文件顯示與導致此錯誤的進程相關的信息。


通過顯示的服務名您可以知道是哪個容器發生了錯誤。


跟蹤文件還提供了摘要 heap dump(堆轉儲)。在本例中,主堆具有 2159MB 的“koh-kghu call”。在該堆中,子堆包括 2154 MB 的“pl/sql vc2”。可以使用這些內容在 MOS 上搜索有關這些分配的任何已知問題。諸如這樣一些與 pl/sql 相關的分配通常是 pl/sql 程序一次性將大量數據加載到內存中造成的。在這樣的情況下,應該變更程序,一次將有限數量的記錄加載到內存中。替代方法是允許這樣大的分配並增加 pga_aggregate_limit 的值


 


*** SERVICE NAME:(pdb1.example.com) 2013-01-28 07:44:27.902  <===-----------請注意指示哪個容器出現錯誤的服務的名稱。

*** MODULE NAME:(SQL*Plus) 2013-01-28 07:44:27.902

*** ACTION NAME:() 2013-01-28 07:44:27.902

*** CONTAINER ID:(4) 2013-01-28 07:44:27.902

 


*** TRACE FILE RECREATED AFTER BEING REMOVED ***


Process may have gone over pga_aggregate_limit

Just allocated 65536 bytes

Dumping short stack in preparation for potential ORA-4036

----- Abridged Call Stack Trace -----

ksedsts()+313<-ksm_pga_limit_short_stack()+456<-ksm_check_over_limit()+540<-ksmapg()+351<-kghgex()+1426<-kghfnd()+745<-kghalo()+693<-kghgex()

+401<-kghalf()+403<-kghualloc()+794<-kohalmc()+295<-kohalc()+110<-plsm0vc_rsz()+197<-pevm_MOVC_i()+1021<-pfrinstr_MOVC()+52

<-pfrrun_no_tool()+60<-pfrrun()+809<-plsql_run()+617<-peicnt()+287<-kkxexe()+789

----- End of Abridged Call Stack Trace -----

=======================================

PRIVATE MEMORY SUMMARY FOR THIS PROCESS

---------------------------------------

******************************************************

PRIVATE HEAP SUMMARY DUMP

2161 MB total:

  2161 MB commented, 261 KB permanent

   481 KB free (256 KB in empty extents),

    2159 MB,   1 heap:    "koh-kghu call  "            1 KB free held  <=============指示在 pga 中使用內存的命名內存分配

------------------------------------------------------

Summary of subheaps at depth 1

2155 MB total:

  2155 MB commented, 104 KB permanent

   295 KB free (20 KB in empty extents),

    2154 MB, 138274 chunks:  "pl/sql vc2                " <--------------------指示 pga heap(堆)中包含的子堆內存分配


*** 2013-01-28 07:44:28.045

Incident 79480 created, dump file: /u01/app/oracle/diag/rdbms/cdb1/cdb1/incident/incdir_79480/cdb1_ora_5349_i79480.trc

ORA-04036: PGA memory used by the instance exceeds PGA_AGGREGATE_LIMIT


*********START PLSQL RUNTIME DUMP************

***Got internal error Exception caught in pl/sql run-time while running PLSQL***

***Got ORA-4036 while running PLSQL***

PROCEDURE SYSTEM.FILL_MEMORY:

意外事件文件顯示程序堆棧及行號


Dump continued from file: /u01/app/oracle/diag/rdbms/cdb1/cdb1/trace/cdb1_ora_5349.trc

ORA-04036: PGA memory used by the instance exceeds PGA_AGGREGATE_LIMIT


========= Dump for incident 79480 (ORA 4036) ========


*** 2013-01-28 07:44:28.045

dbkedDefDump(): Starting incident default dumps (flags=0x2, level=3, mask=0x0)

----- Current SQL Statement for this session (sql_id=gqbtzt92rm1ck) -----

BEGIN fill_memory(2680000); END;

----- PL/SQL Stack -----

----- PL/SQL Call Stack -----

  object      line  object

  handle    number  name

0x77335850         7  procedure SYSTEM.FILL_MEMORY <-------程序的行號

0x77238760         1  anonymous block


----- Call Stack Trace -----



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章