Re: simplehash: preserve consistency in case of OOM - Mailing list pgsql-hackers

From Jeff Davis
Subject Re: simplehash: preserve consistency in case of OOM
Date
Msg-id 1e4dc513f7feb4df416db1bf74424156131ceb63.camel@j-davis.com
Whole thread Raw
In response to Re: simplehash: preserve consistency in case of OOM  (Andres Freund <andres@anarazel.de>)
Responses Re: simplehash: preserve consistency in case of OOM
List 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




pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: ResourceOwner refactoring
Next
From: Gurjeet Singh
Date:
Subject: Re: simplehash: preserve consistency in case of OOM