PostgreSQL fails to start inside Nix' darwin sandbox - Mailing list pgsql-bugs

From Wolfgang Walther
Subject PostgreSQL fails to start inside Nix' darwin sandbox
Date
Msg-id a90b5411-705f-4286-bd81-a26c520a6cfb@technowledgy.de
Whole thread Raw
List pgsql-bugs
Nix on Linux runs all builds and tests in a sandboxed environment by 
default.  Nix on Darwin/macOS doesn't enable the sandbox by default, 
because macOS' native sandboxing capabilities are limited.  We'd like to 
enable the sandbox by default in the future.  Currently, this prevents 
running PostgreSQL's test suite or building extensions with cargo-pgrx, 
both of which require *running* initdb / postgres inside the sandbox.

This is because the Darwin sandbox doesn't allow creating System V 
shared memory segments.  Nix' Linux sandbox is able to create IPC 
namespaces, which allows creating these safely.  To our knowledge it's 
not possible to create these namespaces with the native darwin 
sandboxing capabilities.  Enabling IPC regardless would allow 
communicating with other sandboxes and the host system, defeating the 
point of the sandbox.

System V shared memory segments are used by PostgreSQL to provide a lock 
on the data directory, as explained in sysv_shmem.c.  The comment also 
mentions the possibility to introduce a compile and/or run-time test 
here.  For our use-case, a run-time test seems much better, because we'd 
want the same binaries to not do this inside the sandbox, but work as 
before when actually run on the host.

Right now, initdb fails with his error:

  FATAL:  could not create shared memory segment: Operation not permitted
  DETAIL:  Failed system call was shmget(key=80109247, size=56, 03600).

It would be great if this was fixed to allow running PostgreSQL in this 
environment.

Thanks,

Wolfgang



pgsql-bugs by date:

Previous
From: "李海洋(陌痕)"
Date:
Subject: 回复:BUG #19040: Memory leak in hashed subplan node due to missing hashtempcxt reset
Next
From: PG Bug reporting form
Date:
Subject: BUG #19045: Applying custom collation rules appears to erase existing rules