Default to dynamic_shared_memory_type=sysv on Solaris.
authorThomas Munro <[email protected]>
Sat, 2 Jul 2022 04:06:47 +0000 (16:06 +1200)
committerThomas Munro <[email protected]>
Sat, 2 Jul 2022 04:23:39 +0000 (16:23 +1200)
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 389869af 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

doc/src/sgml/config.sgml
src/backend/utils/misc/postgresql.conf.sample
src/bin/initdb/initdb.c

index 48478b1024acc81e1b27525e18ceb71cc39e78bc..37fd80388c0e602fe7d01a8208b04df84b551cd4 100644 (file)
@@ -2036,7 +2036,7 @@ include_dir 'conf.d'
         and <literal>mmap</literal> (to simulate shared memory using
         memory-mapped files stored in the data directory).
         Not all values are supported on all platforms; the first supported
-        option is the default for that platform.  The use of the
+        option is usually the default for that platform.  The use of the
         <literal>mmap</literal> option, which is not the default on any platform,
         is generally discouraged because the operating system may write
         modified pages back to disk repeatedly, increasing system I/O load;
index 48ad80cf2e847766b76acd1cd8c93df10fe99c53..b4bc06e5f5a636857a8caa104431e5b21ec356aa 100644 (file)
                    #   sysv
                    #   windows
                    # (change requires restart)
-#dynamic_shared_memory_type = posix    # the default is the first option
+#dynamic_shared_memory_type = posix    # the default is usually the first option
                    # supported by the operating system:
                    #   posix
                    #   sysv
index ed6de7ca941346be6cd8db347601198961e68d30..89b888eaa5aa0b1e951aa641ec6639ea034f1f5a 100644 (file)
@@ -842,11 +842,14 @@ set_null_conf(void)
  * segment in dsm_impl.c; if it doesn't work, we assume it won't work for
  * the postmaster either, and configure the cluster for System V shared
  * memory instead.
+ *
+ * We avoid choosing Solaris's implementation of shm_open() by default.  It
+ * can sleep and fail spuriously under contention.
  */
 static const char *
 choose_dsm_implementation(void)
 {
-#ifdef HAVE_SHM_OPEN
+#if defined(HAVE_SHM_OPEN) && !defined(__sun__)
    int         ntries = 10;
    pg_prng_state prng_state;