Re: [PATCH] Make ENOSPC not fatal in semaphore creation

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Mikhail <mp39590(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] Make ENOSPC not fatal in semaphore creation
Date: 2021-10-17 21:07:40
Message-ID: CA+hUKG+9uSLQCGT06nANFdam2m+iuSKEyL7SzRbyXCx8g8oesg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Oct 18, 2021 at 4:49 AM Mikhail <mp39590(at)gmail(dot)com> wrote:
> The logic works - the initial call to semget() in
> InternalIpcSemaphoreCreate returns -1 and errno is set to ENOSPC - I
> tested the patch on OpenBSD 7.0, it successfully recycles sem's after
> previous "pkill -6 postgres". Verified it with 'ipcs -s'.

Since you mentioned OpenBSD, what do you think of the idea of making
named POSIX semas the default on that platform? You can't run out of
those practically speaking, but then you get lots of little memory
mappings (from memory, at least it does close the fd for each one,
unlike some other OSes where we wouldn't want to use this technique).
Trivial patch:

https://www.postgresql.org/message-id/CA%2BhUKGJVSjiDjbJpHwUrvA1TikFnJRfyJanrHofAWhnqcDJayQ%40mail.gmail.com

No strong opinion on the tradeoffs here, as I'm not an OpenBSD user,
but it's something I think about whenever testing portability stuff
there and having to adjust the relevant sysctls.

Note: The best kind would be *unnamed* POSIX semas, where we get to
control their placement in existing memory; that's what we do on Linux
and FreeBSD. They weren't supported on OpenBSD last time we checked:
it rejects requests for shared ones. I wonder if someone could
implement them with just a few lines of user space code, using atomic
counters and futex() for waiting.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2021-10-17 21:11:49 Re: XTS cipher mode for cluster file encryption
Previous Message Vik Fearing 2021-10-17 21:04:15 Re: [PATCH] Proposal for HIDDEN/INVISIBLE column