Thank you very much for your fast answers (both Tom and Merlin), I really appreciate it.
Do I have to send a proper bug report for this?
We have this problem in our product now, so I volunteer to test a patch :-)
Best regards,
Per-Olov Esgård
-----Tom Lane <tgl@xxxxxxxxxxxxx> wrote: -----
-----Tom Lane <tgl@xxxxxxxxxxxxx> wrote: -----
To: Per-Olov Esgard <Per-Olov.Esgard@xxxxxxxxxxxxxxxxxxx>
From: Tom Lane <tgl@xxxxxxxxxxxxx>
Date: 05/27/2011 05:28PM
Cc: Merlin Moncure <mmoncure@xxxxxxxxx>, pgsql-general@xxxxxxxxxxxxxx
Subject: Re: Is there any problem with pg_notify and memory consumption?
Per-Olov Esgard <Per-Olov.Esgard@xxxxxxxxxxxxxxxxxxx> writes:
> This is my setup:
> - linux kernel 2.6.20.16 in a custom OS installation based on Fedora Core
> 3, yes I know, stone age :-)
> - memory 512 MB
> - swap 512 MB
> - cpu p4 2.8 GHz - single core - no hyper threading
> - db encoding UTF-8
> - client encoding default Latin-1 (Linux client) but UTF-8 used for
> Windows clients
> - postgresql.conf is attached as well as the environment variables
> - we build the postgres server ourselves and the dev env is the same as
> the target env (no cross compilation).
Hah, I replicated the problem. Here is what's going on: the main loop
in PostgresMain is intended to do its work in MessageContext. But if
ProcessCompletedNotifies does any work, it exits with
CurrentMemoryContext having been reset to TopMemoryContext during
transaction commit. This means any memory that the main loop doesn't
bother to explicitly free during the next command cycle will get leaked.
The reason we haven't noticed this seems to be that the only case where
any such memory does get leaked is if we have to do encoding conversion
on the incoming command. Also, the bug has only been there since 9.0.
I think the right fix is to make sure that ProcessCompletedNotifies
saves and restores the call-time CurrentMemoryContext.
regards, tom lane
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.