Re: simplehash: preserve consistency in case of OOM

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: simplehash: preserve consistency in case of OOM
Date: 2023-11-17 21:00:19
Message-ID: 1e4dc513f7feb4df416db1bf74424156131ceb63.camel@j-davis.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 2023-11-17 at 12:13 -0800, Andres Freund wrote:
> On 2023-11-17 10:42:54 -0800, Jeff Davis wrote:
> > Right now, if allocation fails while growing a hashtable, it's left
> > in
> > an inconsistent state and can't be used again.
>
> I'm not against allowing this - but I am curious, in which use cases
> is this
> useful?

I committed a cache for search_path (f26c2368dc), and afterwards got
concerned that I missed some potential OOM hazards. I separately posted
a patch to fix those (mostly by simplifying things, which in hindsight
was how it should have been done to begin with). Along the way, I also
noticed that simplehash itself is not safe in that case.

I don't think there are other bugs in the system due to simplehash and
OOM, because it's mainly used in the executor.

Please tell me if you think the use of simplehash for a search_path
cache is the wrong tool for the job.

> Maybe add a comment explaining why it's important to update
> parameters after
> allocating?

Will do.

Regards,
Jeff Davis

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gurjeet Singh 2023-11-17 21:00:59 Re: simplehash: preserve consistency in case of OOM
Previous Message Andres Freund 2023-11-17 20:52:10 Re: ResourceOwner refactoring