public inbox for [email protected]
help / color / mirror / Atom feedFrom: Fujii Masao <[email protected]>
To: Robert Haas <[email protected]>
Cc: Josh Berkus <[email protected]>
Cc: Kevin Grittner <[email protected]>
Cc: Tom Lane <[email protected]>
Cc: Heikki Linnakangas <[email protected]>
Cc: [email protected]
Cc: PostgreSQL-development <[email protected]>
Subject: Re: [HACKERS] Streaming replication document improvements
Date: Fri, 2 Apr 2010 15:06:04 +0900
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
On Fri, Apr 2, 2010 at 2:58 AM, Robert Haas <[email protected]> wrote:
> It's probably also easy to fix so that it doesn't NEED to be documented.
>
> The thing is, when dealing with new features, we reduce our overall
> maintenance burden if we get it right the first time. Obviously it's
> too late for major changes, but minor adjustments to maintain the POLA
> seem like exactly what we SHOULD be doing right now.
The attached patch implements the Heikki's proposal:
----------
ReservedBackends = superuser_reserved_connections + max_wal_senders
MaxBackends = max_connections + autovacuum_max_workers + max_wal_senders + 1
----------
This change looks like minor adjustments rather than major changes.
I have one question:
In the patch, max_wal_senders is ignored by CheckRequiredParameterValues()
as autovacuum_max_workers is already. Is this OK for HS?
Regards,
--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center
Attachments:
[application/octet-stream] replication_connections_v1.patch (9.1K, 2-replication_connections_v1.patch)
download | inline diff:
*** a/src/backend/postmaster/postmaster.c
--- b/src/backend/postmaster/postmaster.c
***************
*** 162,175 **** char *ListenAddresses;
/*
* ReservedBackends is the number of backends reserved for superuser use.
! * This number is taken out of the pool size given by MaxBackends so
! * number of backend slots available to non-superusers is
! * (MaxBackends - ReservedBackends). Note what this really means is
! * "if there are <= ReservedBackends connections available, only superusers
! * can make new connections" --- pre-existing superuser connections don't
! * count against the limit.
*/
! int ReservedBackends;
/* The socket(s) we're listening to. */
#define MAXLISTEN 64
--- 162,177 ----
/*
* ReservedBackends is the number of backends reserved for superuser use.
! * This number is ReservedConnections + max_wal_senders (it is computed by
! * the GUC assign hooks for those variables) and taken out of the pool size
! * given by MaxBackends so number of backend slots available to
! * non-superusers is (MaxBackends - ReservedBackends). Note what this
! * really means is "if there are <= ReservedBackends connections available,
! * only superusers can make new connections" --- pre-existing superuser
! * connections don't count against the limit.
*/
! int ReservedBackends = 3;
! int ReservedConnections = 3;
/* The socket(s) we're listening to. */
#define MAXLISTEN 64
*** a/src/backend/storage/lmgr/proc.c
--- b/src/backend/storage/lmgr/proc.c
***************
*** 142,149 **** ProcGlobalSemas(void)
* running out when trying to start another backend is a common failure.
* So, now we grab enough semaphores to support the desired max number
* of backends immediately at initialization --- if the sysadmin has set
! * MaxConnections or autovacuum_max_workers higher than his kernel will
! * support, he'll find out sooner rather than later.
*
* Another reason for creating semaphores here is that the semaphore
* implementation typically requires us to create semaphores in the
--- 142,149 ----
* running out when trying to start another backend is a common failure.
* So, now we grab enough semaphores to support the desired max number
* of backends immediately at initialization --- if the sysadmin has set
! * MaxConnections, autovacuum_max_workers, or max_wal_senders higher
! * than his kernel will support, he'll find out sooner rather than later.
*
* Another reason for creating semaphores here is that the semaphore
* implementation typically requires us to create semaphores in the
***************
*** 158,163 **** InitProcGlobal(void)
--- 158,164 ----
{
PGPROC *procs;
int i;
+ int numconn;
bool found;
/* Create the ProcGlobal shared structure */
***************
*** 185,197 **** InitProcGlobal(void)
/*
* Pre-create the PGPROC structures and create a semaphore for each.
*/
! procs = (PGPROC *) ShmemAlloc((MaxConnections) * sizeof(PGPROC));
if (!procs)
ereport(FATAL,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of shared memory")));
! MemSet(procs, 0, MaxConnections * sizeof(PGPROC));
! for (i = 0; i < MaxConnections; i++)
{
PGSemaphoreCreate(&(procs[i].sem));
procs[i].links.next = (SHM_QUEUE *) ProcGlobal->freeProcs;
--- 186,199 ----
/*
* Pre-create the PGPROC structures and create a semaphore for each.
*/
! numconn = MaxConnections + max_wal_senders;
! procs = (PGPROC *) ShmemAlloc((numconn) * sizeof(PGPROC));
if (!procs)
ereport(FATAL,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of shared memory")));
! MemSet(procs, 0, numconn * sizeof(PGPROC));
! for (i = 0; i < numconn; i++)
{
PGSemaphoreCreate(&(procs[i].sem));
procs[i].links.next = (SHM_QUEUE *) ProcGlobal->freeProcs;
*** a/src/backend/utils/init/globals.c
--- b/src/backend/utils/init/globals.c
***************
*** 100,107 **** int maintenance_work_mem = 16384;
/*
* Primary determinants of sizes of shared-memory structures. MaxBackends is
! * MaxConnections + autovacuum_max_workers + 1 (it is computed by the GUC
! * assign hooks for those variables):
*/
int NBuffers = 1000;
int MaxBackends = 100;
--- 100,107 ----
/*
* Primary determinants of sizes of shared-memory structures. MaxBackends is
! * MaxConnections + autovacuum_max_workers + 1 + max_wal_senders (it is
! * computed by the GUC assign hooks for those variables):
*/
int NBuffers = 1000;
int MaxBackends = 100;
*** a/src/backend/utils/misc/guc.c
--- b/src/backend/utils/misc/guc.c
***************
*** 172,178 **** static const char *show_tcp_keepalives_idle(void);
--- 172,180 ----
static const char *show_tcp_keepalives_interval(void);
static const char *show_tcp_keepalives_count(void);
static bool assign_maxconnections(int newval, bool doit, GucSource source);
+ static bool assign_reserved_connections(int newval, bool doit, GucSource source);
static bool assign_autovacuum_max_workers(int newval, bool doit, GucSource source);
+ static bool assign_max_wal_senders(int newval, bool doit, GucSource source);
static bool assign_effective_io_concurrency(int newval, bool doit, GucSource source);
static const char *assign_pgstat_temp_directory(const char *newval, bool doit, GucSource source);
static const char *assign_application_name(const char *newval, bool doit, GucSource source);
***************
*** 1361,1367 **** static struct config_int ConfigureNamesInt[] =
* Note: MaxBackends is limited to INT_MAX/4 because some places compute
* 4*MaxBackends without any overflow check. This check is made in
* assign_maxconnections, since MaxBackends is computed as MaxConnections
! * plus autovacuum_max_workers plus one (for the autovacuum launcher).
*
* Likewise we have to limit NBuffers to INT_MAX/2.
*
--- 1363,1370 ----
* Note: MaxBackends is limited to INT_MAX/4 because some places compute
* 4*MaxBackends without any overflow check. This check is made in
* assign_maxconnections, since MaxBackends is computed as MaxConnections
! * plus autovacuum_max_workers plus one (for the autovacuum launcher)
! * plus max_wal_senders.
*
* Likewise we have to limit NBuffers to INT_MAX/2.
*
***************
*** 1390,1397 **** static struct config_int ConfigureNamesInt[] =
gettext_noop("Sets the number of connection slots reserved for superusers."),
NULL
},
! &ReservedBackends,
! 3, 0, INT_MAX / 4, NULL, NULL
},
{
--- 1393,1400 ----
gettext_noop("Sets the number of connection slots reserved for superusers."),
NULL
},
! &ReservedConnections,
! 3, 0, INT_MAX / 4, assign_reserved_connections, NULL
},
{
***************
*** 1706,1712 **** static struct config_int ConfigureNamesInt[] =
NULL
},
&max_wal_senders,
! 0, 0, INT_MAX / 4, NULL, NULL
},
{
--- 1709,1715 ----
NULL
},
&max_wal_senders,
! 0, 0, INT_MAX / 4, assign_max_wal_senders, NULL
},
{
***************
*** 7819,7829 **** show_tcp_keepalives_count(void)
static bool
assign_maxconnections(int newval, bool doit, GucSource source)
{
! if (newval + autovacuum_max_workers + 1 > INT_MAX / 4)
return false;
if (doit)
! MaxBackends = newval + autovacuum_max_workers + 1;
return true;
}
--- 7822,7844 ----
static bool
assign_maxconnections(int newval, bool doit, GucSource source)
{
! if (newval + autovacuum_max_workers + 1 + max_wal_senders > INT_MAX / 4)
return false;
if (doit)
! MaxBackends = newval + autovacuum_max_workers + 1 + max_wal_senders;
!
! return true;
! }
!
! static bool
! assign_reserved_connections(int newval, bool doit, GucSource source)
! {
! if (newval + max_wal_senders > INT_MAX / 4)
! return false;
!
! if (doit)
! ReservedBackends = newval + max_wal_senders;
return true;
}
***************
*** 7831,7841 **** assign_maxconnections(int newval, bool doit, GucSource source)
static bool
assign_autovacuum_max_workers(int newval, bool doit, GucSource source)
{
! if (MaxConnections + newval + 1 > INT_MAX / 4)
return false;
if (doit)
! MaxBackends = MaxConnections + newval + 1;
return true;
}
--- 7846,7872 ----
static bool
assign_autovacuum_max_workers(int newval, bool doit, GucSource source)
{
! if (MaxConnections + newval + 1 + max_wal_senders > INT_MAX / 4)
return false;
if (doit)
! MaxBackends = MaxConnections + newval + 1 + max_wal_senders;
!
! return true;
! }
!
! static bool
! assign_max_wal_senders(int newval, bool doit, GucSource source)
! {
! if (MaxConnections + autovacuum_max_workers + 1 + newval > INT_MAX / 4 ||
! ReservedConnections + newval > INT_MAX / 4)
! return false;
!
! if (doit)
! {
! MaxBackends = MaxConnections + autovacuum_max_workers + 1 + newval;
! ReservedBackends = ReservedConnections + newval;
! }
return true;
}
*** a/src/include/postmaster/postmaster.h
--- b/src/include/postmaster/postmaster.h
***************
*** 17,22 ****
--- 17,23 ----
extern bool EnableSSL;
extern bool SilentMode;
extern int ReservedBackends;
+ extern int ReservedConnections;
extern int PostPortNumber;
extern int Unix_socket_permissions;
extern char *Unix_socket_group;
view thread (34+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: [HACKERS] Streaming replication document improvements
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox