Re: Fixing memory leaks in postgres_fdw

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Matheus Alcantara <matheusssilv97(at)gmail(dot)com>
Cc: Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Fixing memory leaks in postgres_fdw
Date: 2025-05-28 20:56:32
Message-ID: 1696019.1748465792@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> Having said that, the idea that this sequence is OOM-safe is pretty
> silly anyway, considering that createNewConnection does a pstrdup,
> and creates a new hashtable entry which might require enlarging the
> hashtable, and for that matter might even create the hashtable.
> So maybe rather than continuing to adhere to a half-baked coding
> rule, we need to think of some other way to do that.

Here's an attempt at fixing this properly. I'm posting it as a
standalone patch because I now think this part might be worth
back-patching. The odds of an OOM at just the wrong time aren't
high, but losing track of an open connection seems pretty bad.

regards, tom lane

Attachment Content-Type Size
v5-0001-Avoid-resource-leaks-when-a-dblink-connection-fai.patch text/x-diff 8.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sami Imseih 2025-05-28 21:05:03 Re: queryId constant squashing does not support prepared statements
Previous Message Kevin K Biju 2025-05-28 20:40:50 Re: Add CHECK_FOR_INTERRUPTS in polling loop code path in XactLockTableWait