Re: `pg_ctl init` crashes when run concurrently; semget(2) suspected
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Gavin Panella <gavinpanella@gmail.com>
Cc: pgsql-hackers@postgresql.org
Date: 2025-08-10T21:54:03Z
Lists: pgsql-hackers
Attachments
- sematest.c (text/x-c)
I wrote: > This is from current macOS, but equivalent text appears on Linux and > in the POSIX spec. So it's just luck that nobody has reported the > same problem elsewhere --- unless maybe there is some macOS-specific > behavior making it more likely that different installs would try the > same key. Hmm, no, there is a platform dependency here. I made the attached test program to see what happens when there's a key collision, and on Linux I get semget(SEMAS_PER_SET) failed: File exists semget(SEMAS_PER_SET + 1) failed: File exists but macOS and NetBSD give semget(SEMAS_PER_SET) failed: File exists semget(SEMAS_PER_SET + 1) failed: Invalid argument I didn't try other BSDen; this might be a NetBSD-ism that Apple inherited, or maybe it's common among the BSDen. I don't see any text in POSIX specifying which errno is to be returned in this case, so we can't really argue that the behavior is wrong. regards, tom lane
Commits
-
Don't treat EINVAL from semget() as a hard failure.
- 21fddb3d7690 19 (unreleased) landed
- f4c0883448d8 15.15 landed
- e67d5f7baa7d 16.11 landed
- e3b3fa863810 13.23 landed
- b3d6e8b63bc1 14.20 landed
- ab92f0e7f7d7 17.7 landed
- 787cd2b7d5cd 18.0 landed
-
Give up on running with NetBSD/OpenBSD's default semaphore settings.
- 810a8b1c8051 18.0 cited