Skip to content

Commit 94ebf81

Browse files
committed
Default to dynamic_shared_memory_type=sysv on Solaris.
POSIX shm_open() can sleep for a long time and fail spuriously because of contention on an internal lock file on Solaris (and presumably illumos). Commit 389869a fixed the main problem with this, namely that we could crash, but it's now clear that "posix" is not a good default. Therefore, choose "sysv" at initdb time on Solaris and illumos. Other choices are still available by editing the postgresql.conf file. Back-patch only to 15, because contention is much less likely further back, and it doesn't seem like a good idea to change this in released branches. This should clear up the failures on build farm animal margay. Discussion: https://postgr.es/m/CA%2BhUKGKqKrCV5xKWfh9rnm%3Do%3DDwZLTLtnsj_XpUi9g5%3DV%2B9oyg%40mail.gmail.com
1 parent 0507977 commit 94ebf81

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

doc/src/sgml/config.sgml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2036,7 +2036,7 @@ include_dir 'conf.d'
20362036
and <literal>mmap</literal> (to simulate shared memory using
20372037
memory-mapped files stored in the data directory).
20382038
Not all values are supported on all platforms; the first supported
2039-
option is the default for that platform. The use of the
2039+
option is usually the default for that platform. The use of the
20402040
<literal>mmap</literal> option, which is not the default on any platform,
20412041
is generally discouraged because the operating system may write
20422042
modified pages back to disk repeatedly, increasing system I/O load;

src/backend/utils/misc/postgresql.conf.sample

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147
# sysv
148148
# windows
149149
# (change requires restart)
150-
#dynamic_shared_memory_type = posix # the default is the first option
150+
#dynamic_shared_memory_type = posix # the default is usually the first option
151151
# supported by the operating system:
152152
# posix
153153
# sysv

src/bin/initdb/initdb.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -842,11 +842,14 @@ set_null_conf(void)
842842
* segment in dsm_impl.c; if it doesn't work, we assume it won't work for
843843
* the postmaster either, and configure the cluster for System V shared
844844
* memory instead.
845+
*
846+
* We avoid choosing Solaris's implementation of shm_open() by default. It
847+
* can sleep and fail spuriously under contention.
845848
*/
846849
static const char *
847850
choose_dsm_implementation(void)
848851
{
849-
#ifdef HAVE_SHM_OPEN
852+
#if defined(HAVE_SHM_OPEN) && !defined(__sun__)
850853
int ntries = 10;
851854
pg_prng_state prng_state;
852855

0 commit comments

Comments
 (0)