diff options
Diffstat (limited to 'src/backend/utils')
| -rw-r--r-- | src/backend/utils/init/globals.c | 9 | ||||
| -rw-r--r-- | src/backend/utils/misc/guc.c | 51 | ||||
| -rw-r--r-- | src/backend/utils/misc/postgresql.conf.sample | 1 |
3 files changed, 54 insertions, 7 deletions
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c index 130244b5e55..b5b11500566 100644 --- a/src/backend/utils/init/globals.c +++ b/src/backend/utils/init/globals.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/init/globals.c,v 1.100 2007/01/05 22:19:44 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/init/globals.c,v 1.101 2007/04/16 18:29:54 alvherre Exp $ * * NOTES * Globals used all over the place should be declared here and not @@ -95,9 +95,14 @@ bool allowSystemTableMods = false; int work_mem = 1024; int maintenance_work_mem = 16384; -/* Primary determinants of sizes of shared-memory structures: */ +/* + * Primary determinants of sizes of shared-memory structures. MaxBackends is + * MaxConnections + autovacuum_max_workers (it is computed by the GUC assign + * hook): + */ int NBuffers = 1000; int MaxBackends = 100; +int MaxConnections = 90; int VacuumCostPageHit = 1; /* GUC parameters for vacuum */ int VacuumCostPageMiss = 10; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 385411c0582..83ea00c568a 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -10,7 +10,7 @@ * Written by Peter Eisentraut <peter_e@gmx.net>. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.384 2007/04/12 06:53:47 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.385 2007/04/16 18:29:55 alvherre Exp $ * *-------------------------------------------------------------------- */ @@ -163,6 +163,8 @@ static bool assign_tcp_keepalives_count(int newval, bool doit, GucSource source) static const char *show_tcp_keepalives_idle(void); static const char *show_tcp_keepalives_interval(void); static const char *show_tcp_keepalives_count(void); +static bool assign_autovacuum_max_workers(int newval, bool doit, GucSource source); +static bool assign_maxconnections(int newval, bool doit, GucSource source); /* * GUC option variables that are exported from this module @@ -1149,16 +1151,19 @@ static struct config_int ConfigureNamesInt[] = * number. * * MaxBackends is limited to INT_MAX/4 because some places compute - * 4*MaxBackends without any overflow check. Likewise we have to limit - * NBuffers to INT_MAX/2. + * 4*MaxBackends without any overflow check. This check is made on + * assign_maxconnections, since MaxBackends is computed as MaxConnections + + * autovacuum_max_workers. + * + * Likewise we have to limit NBuffers to INT_MAX/2. */ { {"max_connections", PGC_POSTMASTER, CONN_AUTH_SETTINGS, gettext_noop("Sets the maximum number of concurrent connections."), NULL }, - &MaxBackends, - 100, 1, INT_MAX / 4, NULL, NULL + &MaxConnections, + 100, 1, INT_MAX / 4, assign_maxconnections, NULL }, { @@ -1622,6 +1627,15 @@ static struct config_int ConfigureNamesInt[] = &autovacuum_freeze_max_age, 200000000, 100000000, 2000000000, NULL, NULL }, + { + /* see max_connections */ + {"autovacuum_max_workers", PGC_POSTMASTER, AUTOVACUUM, + gettext_noop("Sets the maximum number of simultaneously running autovacuum worker processes."), + NULL + }, + &autovacuum_max_workers, + 3, 1, INT_MAX / 4, assign_autovacuum_max_workers, NULL + }, { {"tcp_keepalives_idle", PGC_USERSET, CLIENT_CONN_OTHER, @@ -6692,5 +6706,32 @@ show_tcp_keepalives_count(void) return nbuf; } +static bool +assign_maxconnections(int newval, bool doit, GucSource source) +{ + if (doit) + { + if (newval + autovacuum_max_workers > INT_MAX / 4) + return false; + + MaxBackends = newval + autovacuum_max_workers; + } + + return true; +} + +static bool +assign_autovacuum_max_workers(int newval, bool doit, GucSource source) +{ + if (doit) + { + if (newval + MaxConnections > INT_MAX / 4) + return false; + + MaxBackends = newval + MaxConnections; + } + + return true; +} #include "guc-file.c" diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 22f9685bbdc..bc5b642d029 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -376,6 +376,7 @@ #autovacuum = on # enable autovacuum subprocess? # 'on' requires stats_start_collector # and stats_row_level to also be on +#autovacuum_max_workers = 3 # max # of autovacuum subprocesses #autovacuum_naptime = 1min # time between autovacuum runs #autovacuum_vacuum_threshold = 500 # min # of tuple updates before # vacuum |
