Re: WaitEventSet resource leakage

Heikki Linnakangas <hlinnaka@iki.fi>

From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@lists.postgresql.org, Alexander Lakhin <exclusion@gmail.com>
Date: 2023-11-16T10:21:49Z
Lists: pgsql-hackers

Attachments

On 16/11/2023 01:08, Tom Lane wrote:
> Heikki Linnakangas <hlinnaka@iki.fi> writes:
>> On 09/03/2023 20:51, Tom Lane wrote:
>>> After further thought that seems like a pretty ad-hoc solution.
>>> We probably can do no better in the back branches, but shouldn't
>>> we start treating WaitEventSets as ResourceOwner-managed resources?
>>> Otherwise, transient WaitEventSets are going to be a permanent
>>> source of headaches.
> 
>> Let's change it so that it's always allocated in TopMemoryContext, but
>> pass a ResourceOwner instead:
>> WaitEventSet *
>> CreateWaitEventSet(ResourceOwner owner, int nevents)
>> And use owner == NULL to mean session lifetime.
> 
> WFM.  (I didn't study your back-branch patch.)

And here is a patch to implement that on master.

-- 
Heikki Linnakangas
Neon (https://neon.tech)

Commits

  1. Fix resource leak when a FDW's ForeignAsyncRequest function fails

  2. Use ResourceOwner to track WaitEventSets.