Re: several problems in pg_receivexlog

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: several problems in pg_receivexlog
Date: 2012-07-12 11:35:11
Message-ID: CABUevEwWY=4GR9Ao6ruu8RZyH4UMFkzeZ41+GRzoUTxTj-O9MA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jul 10, 2012 at 6:45 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> On Tue, Jul 10, 2012 at 6:27 AM, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
>> On Mon, Jul 9, 2012 at 8:23 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>>> Hi,
>>>
>>> I found several problems in pg_receivexlog, e.g., memory leaks,
>>> file-descripter leaks, ..etc. The attached patch fixes these problems.
>>
>> While I don't doubt that what you've found are real problems, would
>> you mind explaining exactly what they are, so we don't have to
>> reverse-engineer the patch to figure that out?
>
> Yep.
>
> When an error happens after replication connection has been established,
> pg_receivexlog doesn't close an open file descriptor and release an allocated
> memory area. This was harmless before 16282ae688de2b320cf176e9be8a89e4dfc60698
> because pg_receivexlog exits immediately when an error happens. But
> currently in an error case, pg_receivexlog tries reconnecting to the server
> infinitely, so file descriptors and memory would leak. I think this is problem
> and should be fixed. The patch which I submitted yesterday changes
> pg_receivexlog so that it closes the open file and frees the memory area
> before reconnecting to the server.

Thanks. I get it now, and this explains why I didn't see it before - I
didn't check properly after we added the loop mode. Patch applied with
minor changes (e.g. there's no point in doing PQfinish(tmpconn) right
after you've verified tmpconn is NULL)

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2012-07-12 11:39:13 Re: several problems in pg_receivexlog
Previous Message Shigeru HANADA 2012-07-12 10:44:57 Re: pgsql_fdw in contrib