diff options
author | Alvaro Herrera | 2013-01-02 15:01:14 +0000 |
---|---|---|
committer | Alvaro Herrera | 2013-01-02 15:01:14 +0000 |
commit | cdbc0ca48ca96e5c787b1605ed2d6cf7407a5acf (patch) | |
tree | f8e0e768c9d68dc79de634e35d10beb8f569039d /src/backend/utils | |
parent | d194d7a52630d855f43edbf0129e131099af6c14 (diff) |
Fix background workers for EXEC_BACKEND
Commit da07a1e8 was broken for EXEC_BACKEND because I failed to realize
that the MaxBackends recomputation needed to be duplicated by
subprocesses in SubPostmasterMain. However, instead of having the value
be recomputed at all, it's better to assign the correct value at
postmaster initialization time, and have it be propagated to exec'ed
backends via BackendParameters.
MaxBackends stays as zero until after modules in
shared_preload_libraries have had a chance to register bgworkers, since
the value is going to be untrustworthy till that's finished.
Heikki Linnakangas and Álvaro Herrera
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 | 30 |
2 files changed, 7 insertions, 32 deletions
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c index 00288530c07..f1f8b177f35 100644 --- a/src/backend/utils/init/globals.c +++ b/src/backend/utils/init/globals.c @@ -103,13 +103,14 @@ int work_mem = 1024; 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): + * Primary determinants of sizes of shared-memory structures. + * + * MaxBackends is computed by PostmasterMain after modules have had a chance to + * register background workers. */ int NBuffers = 1000; -int MaxBackends = 100; int MaxConnections = 90; +int MaxBackends = 0; 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 d91924cc234..ac5e4f3e48d 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -103,17 +103,6 @@ #define MAX_KILOBYTES (INT_MAX / 1024) #endif -/* - * Note: MAX_BACKENDS is limited to 2^23-1 because inval.c stores the - * backend ID as a 3-byte signed integer. Even if that limitation were - * removed, we still could not exceed INT_MAX/4 because some places compute - * 4*MaxBackends without any overflow check. This is rechecked in - * check_maxconnections, since MaxBackends is computed as MaxConnections - * plus the number of bgworkers plus autovacuum_max_workers plus one (for the - * autovacuum launcher). - */ -#define MAX_BACKENDS 0x7fffff - #define KB_PER_MB (1024) #define KB_PER_GB (1024*1024) @@ -199,9 +188,7 @@ 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 check_maxconnections(int *newval, void **extra, GucSource source); -static void assign_maxconnections(int newval, void *extra); static bool check_autovacuum_max_workers(int *newval, void **extra, GucSource source); -static void assign_autovacuum_max_workers(int newval, void *extra); static bool check_effective_io_concurrency(int *newval, void **extra, GucSource source); static void assign_effective_io_concurrency(int newval, void *extra); static void assign_pgstat_temp_directory(const char *newval, void *extra); @@ -1615,7 +1602,7 @@ static struct config_int ConfigureNamesInt[] = }, &MaxConnections, 100, 1, MAX_BACKENDS, - check_maxconnections, assign_maxconnections, NULL + check_maxconnections, NULL, NULL }, { @@ -2290,7 +2277,7 @@ static struct config_int ConfigureNamesInt[] = }, &autovacuum_max_workers, 3, 1, MAX_BACKENDS, - check_autovacuum_max_workers, assign_autovacuum_max_workers, NULL + check_autovacuum_max_workers, NULL, NULL }, { @@ -8636,13 +8623,6 @@ check_maxconnections(int *newval, void **extra, GucSource source) return true; } -static void -assign_maxconnections(int newval, void *extra) -{ - MaxBackends = newval + autovacuum_max_workers + 1 + - GetNumShmemAttachedBgworkers(); -} - static bool check_autovacuum_max_workers(int *newval, void **extra, GucSource source) { @@ -8652,12 +8632,6 @@ check_autovacuum_max_workers(int *newval, void **extra, GucSource source) return true; } -static void -assign_autovacuum_max_workers(int newval, void *extra) -{ - MaxBackends = MaxConnections + newval + 1 + GetNumShmemAttachedBgworkers(); -} - static bool check_effective_io_concurrency(int *newval, void **extra, GucSource source) { |