HAWQ-367. Introduce seg_max_connections guc to set segment max_connections 
setting


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/ff98f360
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/ff98f360
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/ff98f360

Branch: refs/heads/HAWQ-369
Commit: ff98f360b2b6c12fb07e7d200c1ab772dcaf80c7
Parents: 1df504f
Author: YI JIN <y...@pivotal.io>
Authored: Fri Jan 29 11:17:22 2016 +1100
Committer: YI JIN <y...@pivotal.io>
Committed: Fri Jan 29 11:17:22 2016 +1100

----------------------------------------------------------------------
 src/backend/postmaster/postmaster.c | 15 +++++++++++++++
 src/backend/tcop/postgres.c         | 15 ++++++++++++++-
 src/backend/utils/init/globals.c    |  1 +
 src/backend/utils/misc/guc.c        | 14 ++++++++++++++
 src/include/miscadmin.h             |  1 +
 5 files changed, 45 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ff98f360/src/backend/postmaster/postmaster.c
----------------------------------------------------------------------
diff --git a/src/backend/postmaster/postmaster.c 
b/src/backend/postmaster/postmaster.c
index bc71d97..f15a6eb 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -1071,9 +1071,24 @@ PostmasterMain(int argc, char *argv[])
         * postgresql.conf for the first time.
         */
        if (!SelectConfigFiles(userDoption, progname))
+
                ExitPostmaster(2);
 
        /*
+        * Overwrite MaxBackends in case it is a segment.
+        */
+       if ( !AmIMaster() && !IsUnderPostmaster)
+       {
+               char segmaxconns[32];
+               elog(LOG, "Update segment max_connections to %d", 
SegMaxBackends);
+               snprintf(segmaxconns, sizeof(segmaxconns), "%d", 
SegMaxBackends);
+               SetConfigOption("max_connections",
+                                               segmaxconns,
+                                               PGC_POSTMASTER,
+                                               PGC_S_OVERRIDE);
+       }
+
+       /*
         * CDB/MPP/GPDB: Set the processor affinity (may be a no-op on
         * some platforms). The port number is nice to use because we know
         * that different segments on a single host will not have the same

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ff98f360/src/backend/tcop/postgres.c
----------------------------------------------------------------------
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 4d3dfe3..71c4c2a 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -3763,7 +3763,6 @@ PostgresMain(int argc, char *argv[], const char *username)
        volatile bool send_ready_for_query = true;
        int                     topErrCode;
 
-
        MemoryAccount *postgresMainMemoryAccount = NULL;
 
     /*
@@ -4145,6 +4144,20 @@ PostgresMain(int argc, char *argv[], const char 
*username)
            PgStartTime = GetCurrentTimestamp();
        }
 
+       /*
+        * Overwrite MaxBackends in case it is a segment.
+        */
+       if ( !AmIMaster() && !IsUnderPostmaster)
+       {
+               char segmaxconns[32];
+               elog(LOG, "Update segment max_connections to %d", 
SegMaxBackends);
+               snprintf(segmaxconns, sizeof(segmaxconns), "%d", 
SegMaxBackends);
+               SetConfigOption("max_connections",
+                                               segmaxconns,
+                                               PGC_POSTMASTER,
+                                               PGC_S_OVERRIDE);
+       }
+
        if (PostAuthDelay)
                pg_usleep(PostAuthDelay * 1000000L);
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ff98f360/src/backend/utils/init/globals.c
----------------------------------------------------------------------
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c
index bd069cf..a7202ae 100644
--- a/src/backend/utils/init/globals.c
+++ b/src/backend/utils/init/globals.c
@@ -116,6 +116,7 @@ int                 maintenance_work_mem = 65536;
 /* Primary determinants of sizes of shared-memory structures: */
 int                    NBuffers = 4096;
 int                    MaxBackends = 200;
+int                    SegMaxBackends = 4800;
 
 int                    gp_workfile_max_entries = 8192; /* Number of unique 
entries we can hold in the workfile directory */
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ff98f360/src/backend/utils/misc/guc.c
----------------------------------------------------------------------
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 845bfdc..ceb378c 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -4617,6 +4617,20 @@ static struct config_int ConfigureNamesInt[] =
                200, 10, MAX_MAX_BACKENDS, NULL, NULL
        },
 
+       /*
+        * When HAWQ has one master and one segment deployed together in one 
physical
+        * machine, we can not separately set different max connection count. 
Thus,
+        * we introduce this guc for segment setting only.
+        */
+       {
+               {"seg_max_connections", PGC_POSTMASTER, CONN_AUTH_SETTINGS,
+                       gettext_noop("Sets the maximum number of concurrent 
connections in a segment."),
+                       NULL
+               },
+               &SegMaxBackends,
+               4800, 240, MAX_MAX_BACKENDS, NULL, NULL
+       },
+
        {
                {"superuser_reserved_connections", PGC_POSTMASTER, 
CONN_AUTH_SETTINGS,
                        gettext_noop("Sets the number of connection slots 
reserved for superusers."),

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/ff98f360/src/include/miscadmin.h
----------------------------------------------------------------------
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 23be5f1..b52485c 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -194,6 +194,7 @@ extern PGDLLIMPORT char *DataDir;
 
 extern PGDLLIMPORT int NBuffers;
 extern int     MaxBackends;
+extern int     SegMaxBackends;
 extern int     MaxConnections;
 extern int gp_workfile_max_entries;
 extern int gp_mdver_max_entries;

Reply via email to