Remove dynamic_shared_memory_type=none
authorPeter Eisentraut <peter_e@gmx.net>
Tue, 10 Jul 2018 15:37:42 +0000 (17:37 +0200)
committerPeter Eisentraut <peter_e@gmx.net>
Tue, 10 Jul 2018 16:35:24 +0000 (18:35 +0200)
PostgreSQL nowadays offers some kind of dynamic shared memory feature on
all supported platforms.  Having the choice of "none" prevents us from
relying on DSM in core features.  So this patch removes the choice of
"none".

Author: Kyotaro Horiguchi <horiguchi.kyotaro@lab.ntt.co.jp>

doc/src/sgml/config.sgml
doc/src/sgml/parallel.sgml
src/backend/access/transam/parallel.c
src/backend/optimizer/plan/planner.c
src/backend/storage/ipc/dsm.c
src/backend/storage/ipc/dsm_impl.c
src/backend/utils/misc/postgresql.conf.sample
src/bin/initdb/initdb.c
src/include/storage/dsm_impl.h

index 5b913f00c1dab74f5656750a3d552ea19b87ef10..e307bb4e8e9643476c03855a4ac13bec933bc596 100644 (file)
@@ -1662,9 +1662,9 @@ include_dir 'conf.d'
         should use.  Possible values are <literal>posix</literal> (for POSIX shared
         memory allocated using <literal>shm_open</literal>), <literal>sysv</literal>
         (for System V shared memory allocated via <literal>shmget</literal>),
-        <literal>windows</literal> (for Windows shared memory), <literal>mmap</literal>
-        (to simulate shared memory using memory-mapped files stored in the
-        data directory), and <literal>none</literal> (to disable this feature).
+        <literal>windows</literal> (for Windows shared memory),
+        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
         <literal>mmap</literal> option, which is not the default on any platform,
index dd7834a763fa9000bea7dcde7d67b83947eda165..e9a015ecd3cb43de99657584ebac9dc4f533d474 100644 (file)
@@ -124,14 +124,6 @@ EXPLAIN SELECT * FROM pgbench_accounts WHERE filler LIKE '%x%';
         configured via <varname>max_parallel_workers_per_gather</varname>.
       </para>
     </listitem>
-
-    <listitem>
-      <para>
-        <xref linkend="guc-dynamic-shared-memory-type"/> must be set to a
-        value other than <literal>none</literal>.  Parallel query requires dynamic
-        shared memory in order to pass data between cooperating processes.
-      </para>
-    </listitem>
   </itemizedlist>
 
   <para>
index 1d631b727552cf235e3f00303e5574ca9c8cb6f2..4e32cfff50020d2efec6351bc49abb5af5b76eef 100644 (file)
@@ -161,13 +161,6 @@ CreateParallelContext(const char *library_name, const char *function_name,
    /* Number of workers should be non-negative. */
    Assert(nworkers >= 0);
 
-   /*
-    * If dynamic shared memory is not available, we won't be able to use
-    * background workers.
-    */
-   if (dynamic_shared_memory_type == DSM_IMPL_NONE)
-       nworkers = 0;
-
    /*
     * If we are running under serializable isolation, we can't use parallel
     * workers, at least not until somebody enhances that mechanism to be
index fd45c9767df7cf888196c066701cab0457d2c2a3..eeebf775a40e66d52ffb02af99edf825d2cd6b08 100644 (file)
@@ -335,7 +335,6 @@ standard_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
     */
    if ((cursorOptions & CURSOR_OPT_PARALLEL_OK) != 0 &&
        IsUnderPostmaster &&
-       dynamic_shared_memory_type != DSM_IMPL_NONE &&
        parse->commandType == CMD_SELECT &&
        !parse->hasModifyingCTE &&
        max_parallel_workers_per_gather > 0 &&
@@ -6050,8 +6049,7 @@ plan_create_index_workers(Oid tableOid, Oid indexOid)
    double      allvisfrac;
 
    /* Return immediately when parallelism disabled */
-   if (dynamic_shared_memory_type == DSM_IMPL_NONE ||
-       max_parallel_maintenance_workers == 0)
+   if (max_parallel_maintenance_workers == 0)
        return 0;
 
    /* Set up largely-dummy planner state */
index f1f75b73f50c056acb7b4354815b9d1a72f282cb..9629f22f7af96d5e9563df119da90f9ee395c112 100644 (file)
@@ -150,10 +150,6 @@ dsm_postmaster_startup(PGShmemHeader *shim)
 
    Assert(!IsUnderPostmaster);
 
-   /* If dynamic shared memory is disabled, there's nothing to do. */
-   if (dynamic_shared_memory_type == DSM_IMPL_NONE)
-       return;
-
    /*
     * If we're using the mmap implementations, clean up any leftovers.
     * Cleanup isn't needed on Windows, and happens earlier in startup for
@@ -219,10 +215,6 @@ dsm_cleanup_using_control_segment(dsm_handle old_control_handle)
    uint32      i;
    dsm_control_header *old_control;
 
-   /* If dynamic shared memory is disabled, there's nothing to do. */
-   if (dynamic_shared_memory_type == DSM_IMPL_NONE)
-       return;
-
    /*
     * Try to attach the segment.  If this fails, it probably just means that
     * the operating system has been rebooted and the segment no longer
@@ -391,13 +383,6 @@ dsm_postmaster_shutdown(int code, Datum arg)
 static void
 dsm_backend_startup(void)
 {
-   /* If dynamic shared memory is disabled, reject this. */
-   if (dynamic_shared_memory_type == DSM_IMPL_NONE)
-       ereport(ERROR,
-               (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
-                errmsg("dynamic shared memory is disabled"),
-                errhint("Set dynamic_shared_memory_type to a value other than \"none\".")));
-
 #ifdef EXEC_BACKEND
    {
        void       *control_address = NULL;
index c6382ec031b8e401cc9ee9d0fe57bc65a0211458..77e1bab54bef1723f3c11fe0f55fe8ff4a76926b 100644 (file)
@@ -106,7 +106,6 @@ const struct config_enum_entry dynamic_shared_memory_options[] = {
 #ifdef USE_DSM_MMAP
    {"mmap", DSM_IMPL_MMAP, false},
 #endif
-   {"none", DSM_IMPL_NONE, false},
    {NULL, 0, false}
 };
 
@@ -210,8 +209,6 @@ dsm_impl_can_resize(void)
 {
    switch (dynamic_shared_memory_type)
    {
-       case DSM_IMPL_NONE:
-           return false;
        case DSM_IMPL_POSIX:
            return true;
        case DSM_IMPL_SYSV:
index 9e39baf46683139d4793a6f64696df98acd268e9..657c3f81f8fac202214c4b220b5d03ba06fdfe8c 100644 (file)
                    #   sysv
                    #   windows
                    #   mmap
-                   # use none to disable dynamic shared memory
                    # (change requires restart)
 
 # - Disk -
index ae22e7d9fb89db67d187aa2e43cfe5db42011d9d..3f203c6ca6d31caf16342a24a457e659c4c515d2 100644 (file)
@@ -984,6 +984,15 @@ test_config_settings(void)
                ok_buffers = 0;
 
 
+   /*
+    * Need to determine working DSM implementation first so that subsequent
+    * tests don't fail because DSM setting doesn't work.
+    */
+   printf(_("selecting dynamic shared memory implementation ... "));
+   fflush(stdout);
+   dynamic_shared_memory_type = choose_dsm_implementation();
+   printf("%s\n", dynamic_shared_memory_type);
+
    printf(_("selecting default max_connections ... "));
    fflush(stdout);
 
@@ -996,10 +1005,11 @@ test_config_settings(void)
                 "\"%s\" --boot -x0 %s "
                 "-c max_connections=%d "
                 "-c shared_buffers=%d "
-                "-c dynamic_shared_memory_type=none "
+                "-c dynamic_shared_memory_type=%s "
                 "< \"%s\" > \"%s\" 2>&1",
                 backend_exec, boot_options,
                 test_conns, test_buffs,
+                dynamic_shared_memory_type,
                 DEVNULL, DEVNULL);
        status = system(cmd);
        if (status == 0)
@@ -1031,10 +1041,11 @@ test_config_settings(void)
                 "\"%s\" --boot -x0 %s "
                 "-c max_connections=%d "
                 "-c shared_buffers=%d "
-                "-c dynamic_shared_memory_type=none "
+                "-c dynamic_shared_memory_type=%s "
                 "< \"%s\" > \"%s\" 2>&1",
                 backend_exec, boot_options,
                 n_connections, test_buffs,
+                dynamic_shared_memory_type,
                 DEVNULL, DEVNULL);
        status = system(cmd);
        if (status == 0)
@@ -1046,11 +1057,6 @@ test_config_settings(void)
        printf("%dMB\n", (n_buffers * (BLCKSZ / 1024)) / 1024);
    else
        printf("%dkB\n", n_buffers * (BLCKSZ / 1024));
-
-   printf(_("selecting dynamic shared memory implementation ... "));
-   fflush(stdout);
-   dynamic_shared_memory_type = choose_dsm_implementation();
-   printf("%s\n", dynamic_shared_memory_type);
 }
 
 /*
index 0e5730f7c5b2e0fe73929c4d6088c199d5a2186e..e7acdff355209cbc623bef188d5ef1a33e1e5082 100644 (file)
@@ -14,7 +14,6 @@
 #define DSM_IMPL_H
 
 /* Dynamic shared memory implementations. */
-#define DSM_IMPL_NONE          0
 #define DSM_IMPL_POSIX         1
 #define DSM_IMPL_SYSV          2
 #define DSM_IMPL_WINDOWS       3