Re: `pg_ctl init` crashes when run concurrently; semget(2) suspected
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Gavin Panella <gavinpanella@gmail.com>, pgsql-hackers@postgresql.org
Date: 2025-08-13T00:45:19Z
Lists: pgsql-hackers
On Wed, Aug 13, 2025 at 11:29 AM Thomas Munro <thomas.munro@gmail.com> wrote: > FWIW in early prototype multithreading patches you can just use > sem_init() on all these systems since you don't need pshared=1. Oops, I misremembered that. It works on NetBSD and OpenBSD, but not macOS :-(. Hmm, but it looks like there has been a new development in macOS 15. They have finally made the futex API public: https://developer.apple.com/documentation/os/os_sync_wait_on_address That was one of the sticking points for my patch that added our own replacement sem_init() implementation. At the time the only "proper" way to reach the undocumented and undeclared __ulock_wait()/__ulock_wake() functions was to write a module in C++ using std::atomic<int>::wait()/notify(), which I had started to wonder about, but here it is with a shiny new C interface and documentation. Maybe I should have another go at that!
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