Re: Is there any problem with pg_notify and memory consumption?

From: Per-Olov Esgard <Per-Olov(dot)Esgard(at)micronic-mydata(dot)com>
To: tgl(at)sss(dot)pgh(dot)pa(dot)us
Cc: mmoncure <mmoncure(at)gmail(dot)com>, Per-Olov Esgard <Per-Olov(dot)Esgard(at)micronic-mydata(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Is there any problem with pg_notify and memory consumption?
Date: 2011-05-27 16:12:50
Message-ID: OFEF9CEF74.631A212F-ONC125789D.005910DB-C125789D.005910DF@micronic-mydata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

<font face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size="2"><DIV>Thank you very much for your fast answers (both Tom and Merlin), I really appreciate it.</DIV>
<DIV>Do I have to send a proper bug report for this?</DIV>
<DIV>We have this problem in our product now, so I volunteer to test a patch&nbsp; :-)</DIV>
<DIV>&nbsp;</DIV>
<DIV>Best regards,</DIV>
<DIV>Per-Olov Esgård<BR><BR><BR><FONT color=#990099>-----Tom Lane &lt;tgl(at)sss(dot)pgh(dot)pa(dot)us&gt; wrote: -----</FONT> </DIV>
<DIV>
<BLOCKQUOTE style="BORDER-LEFT: black 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">To: Per-Olov Esgard &lt;Per-Olov(dot)Esgard(at)micronic-mydata(dot)com&gt;<BR>From: Tom Lane &lt;tgl(at)sss(dot)pgh(dot)pa(dot)us&gt;<BR>Date: 05/27/2011 05:28PM<BR>Cc: Merlin Moncure &lt;mmoncure(at)gmail(dot)com&gt;, pgsql-general(at)postgresql(dot)org<BR>Subject: Re: [GENERAL] Is there any problem with pg_notify and memory consumption?<BR><BR><FONT size=2 face="Default Monospace,Courier New,Courier,monospace">Per-Olov Esgard &lt;Per-Olov(dot)Esgard(at)micronic-mydata(dot)com&gt; writes:<BR>&gt; This is my setup:<BR>&gt; - linux kernel 2.6.20.16 in a custom OS installation based on Fedora Core <BR>&gt; 3, yes I know, stone age :-)<BR>&gt; - memory 512 MB<BR>&gt; - swap 512 MB<BR>&gt; - cpu p4 2.8 GHz - single core - no hyper threading<BR>&gt; - db encoding UTF-8<BR>&gt; - client encoding default Latin-1 (Linux client) but UTF-8 used for <BR>&gt; Windows clients <BR>&gt; - postgresql.conf is attached as well as the environment variables<BR>&gt; - we &nbsp;build the postgres server ourselves and the dev env is the same as <BR>&gt; the target env &nbsp;(no cross compilation).<BR><BR>Hah, I replicated the problem. &nbsp;Here is what's going on: the main loop<BR>in PostgresMain is intended to do its work in MessageContext. &nbsp;But if<BR>ProcessCompletedNotifies does any work, it exits with<BR>CurrentMemoryContext having been reset to TopMemoryContext during<BR>transaction commit. &nbsp;This means any memory that the main loop doesn't<BR>bother to explicitly free during the next command cycle will get leaked.<BR>The reason we haven't noticed this seems to be that the only case where<BR>any such memory does get leaked is if we have to do encoding conversion<BR>on the incoming command. &nbsp;Also, the bug has only been there since 9.0.<BR><BR>I think the right fix is to make sure that ProcessCompletedNotifies<BR>saves and restores the call-time CurrentMemoryContext.<BR><BR>regards, tom lane<BR></FONT></BLOCKQUOTE></DIV>
<DIV><BR>The information contained in this communication and any attachments may be confidential and privileged, and is for the sole use of the intended recipient(s). If you are not the intended recipient, you are hereby formally notified that any unauthorized review, use, disclosure or distribution of this message is prohibited. Please notify the sender immediately by replying to this message and destroy all copies of this message and any attachments. Micronic Mydata is neither liable for the proper and complete transmission of the information contained in this communication, nor for any delay in its receipt.</DIV></font>

Attachment Content-Type Size
unknown_filename text/html 3.1 KB

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Emi Lu 2011-05-27 16:15:00 Re: 500KB PDF files for postgresql8.3, which is the most efficient way?
Previous Message Emi Lu 2011-05-27 16:12:42 500KB PDF files for postgresql8.3, which is the most efficient way?