{"id":277,"date":"2023-02-01T15:27:14","date_gmt":"2023-02-01T14:27:14","guid":{"rendered":"https:\/\/oracledba.fr\/?p=277"},"modified":"2023-02-01T15:27:15","modified_gmt":"2023-02-01T14:27:15","slug":"q-processes-take-more-and-more-memory","status":"publish","type":"post","link":"https:\/\/oracledba.fr\/?p=277","title":{"rendered":"Q Processes take more and more memory"},"content":{"rendered":"\n<p>Q Processes take more and more memory and does not release the memory.<br> pga_aggregate_limit=0 allows pga to grow unlimited hence the Q processes can consume all server memory. <\/p>\n\n\n\n<p>Temporary workaround is to reset the AQ slaves so that it is not necessary to shutdown\/startup the db instance<\/p>\n\n\n\n<pre class=\"wp-block-code has-black-color has-text-color\"><code lang=\"sql\" class=\"language-sql\">show parameter aq_tm_processes\n\n--Reset AQ slaves:\n\nconnect \/ as sysdba\nalter system set aq_tm_processes=0 scope=memory sid='*' ;\n\n--delete AQ SESSIONS\n\nSELECT 'ALTER SYSTEM KILL SESSION ' || CHR(39) || SID || ',' || SERIAL# || CHR(39) || ' IMMEDIATE;'\nFROM V$SESSION \nWHERE TYPE = 'BACKGROUND' AND MODULE = 'Streams' AND ACTION LIKE 'EMON%' AND EVENT = 'EMON slave idle wait'\nORDER BY SID, SERIAL#;\n\n--Start back AQ slaves:\n\nconnect \/ as sysdba\nalter system set aq_tm_processes=1 scope=memory sid='*';\n<\/code><\/pre>\n\n\n\n<p>Queries to Monitor Q Processes.<\/p>\n\n\n\n<pre class=\"wp-block-code has-black-color has-text-color\"><code lang=\"sql\" class=\"language-sql\">--PGA Memory Stat\nSELECT name, round(((value\/1000)\/1024),2) as value_mb, round((((value\/1000)\/1024)\/1024),2) as value_gb FROM V$PGASTAT;\n\n--Find the Q Processes\nSELECT SID,SERIAL#,OSUSER,PROCESS,MACHINE,PROGRAM,TYPE,MODULE,ACTION,EVENT \nFROM V$SESSION \nWHERE TYPE = 'BACKGROUND' AND MODULE = 'Streams' AND ACTION LIKE 'EMON%' AND EVENT = 'EMON slave idle wait'\nORDER BY SID, SERIAL#;\n\n--ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE;\nSELECT 'ALTER SYSTEM KILL SESSION ' || CHR(39) || SID || ',' || SERIAL# || CHR(39) || ' IMMEDIATE;'\nFROM V$SESSION \nWHERE TYPE = 'BACKGROUND' AND MODULE = 'Streams' AND ACTION LIKE 'EMON%' AND EVENT = 'EMON slave idle wait'\nORDER BY SID, SERIAL#;\n\n--03-memory-usage-in-details.sql - Q Processes\nselect\n    to_char(ssn.sid, '999999')                           as session_id,\n    ssn.serial#                                          as session_serial,\n    nvl(ssn.username, nvl(bgp.name, 'background'))\n    || '::'\n    || nvl(lower(ssn.machine), ins.host_name)            as process_name,\n    to_char(prc.spid, '999999999')                       as pid_thread,\n    to_char((se1.value \/ 1024) \/ 1024, '999g999g990d00') as current_size_mb,\n    to_char((se2.value \/ 1024) \/ 1024, '999g999g990d00') as maximum_size_mb\nfrom\n    v$statname    stat1,\n    v$statname    stat2,\n    v$session     ssn,\n    v$sesstat     se1,\n    v$sesstat     se2,\n    v$bgprocess   bgp,\n    v$process     prc,\n    v$instance    ins\nwhere\n    stat1.name         = 'session pga memory'\n    and stat2.name     = 'session pga memory max'\n    and se1.sid        = ssn.sid\n    and se2.sid        = ssn.sid\n    and se2.statistic# = stat2.statistic#\n    and se1.statistic# = stat1.statistic#\n    and ssn.paddr      = bgp.paddr (+)\n    and ssn.paddr      = prc.addr  (+)\n    and ssn.sid in (\n        select sid\n        from v$session\n        --where username = 'MY_USERNAME' -- your user\/schema name\n        where type = 'BACKGROUND' and module = 'Streams' and action like 'EMON%' and event = 'EMON slave idle wait'\n    )\norder by\n    maximum_size_mb desc;<\/code><\/pre>\n\n\n\n<p>Check also that AQ_SRVNTFN_TABLE_1 is set to dequeue. It is possible that DEQUEUE_ENABLED is set to NO.<\/p>\n\n\n\n<p>AQ_SRVNTFN_TABLE_1<br>ENQUEUE_ENABLE=YES<br>DEQUEUE_ENABLED=NO<\/p>\n\n\n\n<p>confirm the status of the queue:<\/p>\n\n\n\n<pre class=\"wp-block-code has-black-color has-text-color\"><code lang=\"sql\" class=\"language-sql\">-- Workaround to apply on all CDB and PDB\nselect ENQUEUE_ENABLED, DEQUEUE_ENABLED from dba_queues where NAME = 'AQ_SRVNTFN_TABLE_Q_1';\n\nselect owner, name, queue_table, ENQUEUE_ENABLED, DEQUEUE_ENABLED \nfrom dba_queues where name = 'AQ_SRVNTFN_TABLE_Q_1' and owner='SYS';\n\nexec dbms_aqadm.stop_queue( 'AQ_SRVNTFN_TABLE_Q_1', true , true );\nexec dbms_aqadm.start_queue( 'AQ_SRVNTFN_TABLE_Q_1' , true, true );\n\n\n<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Q Processes take more and more memory and does not release the memory. pga_aggregate_limit=0 allows pga to grow unlimited hence the Q processes can consume all server memory. Temporary workaround is to reset the AQ slaves so that it is not necessary to shutdown\/startup the db instance Queries to Monitor Q Processes. Check also that &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/oracledba.fr\/?p=277\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Q Processes take more and more memory&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-277","post","type-post","status-publish","format-standard","hentry","category-non-classe"],"_links":{"self":[{"href":"https:\/\/oracledba.fr\/index.php?rest_route=\/wp\/v2\/posts\/277","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oracledba.fr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oracledba.fr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oracledba.fr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oracledba.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=277"}],"version-history":[{"count":2,"href":"https:\/\/oracledba.fr\/index.php?rest_route=\/wp\/v2\/posts\/277\/revisions"}],"predecessor-version":[{"id":279,"href":"https:\/\/oracledba.fr\/index.php?rest_route=\/wp\/v2\/posts\/277\/revisions\/279"}],"wp:attachment":[{"href":"https:\/\/oracledba.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oracledba.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oracledba.fr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}