From dbdfd114f34443f1e4ad16ce2721f9817d3b3d80 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 25 Nov 2016 18:36:10 -0500 Subject: Bring some clarity to the defaults for the xxx_flush_after parameters. Instead of confusingly stating platform-dependent defaults for these parameters in the comments in postgresql.conf.sample (with the main entry being a lie on Linux), teach initdb to install the correct platform-dependent value in postgresql.conf, similarly to the way we handle other platform-dependent defaults. This won't do anything for existing 9.6 installations, but since it's effectively only a documentation improvement, that seems OK. Since this requires initdb to have access to the default values, move the #define's for those to pg_config_manual.h; the original placement in bufmgr.h is unworkable because that file can't be included by frontend programs. Adjust the default value for wal_writer_flush_after so that it is 1MB regardless of XLOG_BLCKSZ, conforming to what is stated in both the SGML docs and postgresql.conf. (We could alternatively make it scale with XLOG_BLCKSZ, but I'm not sure I see the point.) Copy-edit related SGML documentation. Fabien Coelho and Tom Lane, per a gripe from Tomas Vondra. Discussion: <30ebc6e3-8358-09cf-44a8-578252938424@2ndquadrant.com> --- src/bin/initdb/initdb.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/bin/initdb') diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index c8a8c52c3d7..24f9cc8eae2 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -64,11 +64,11 @@ #include "common/file_utils.h" #include "common/restricted_token.h" #include "common/username.h" -#include "mb/pg_wchar.h" +#include "fe_utils/string_utils.h" #include "getaddrinfo.h" #include "getopt_long.h" +#include "mb/pg_wchar.h" #include "miscadmin.h" -#include "fe_utils/string_utils.h" /* Ideally this would be in a .h file, but it hardly seems worth the trouble */ @@ -1095,6 +1095,27 @@ setup_config(void) conflines = replace_token(conflines, "#dynamic_shared_memory_type = posix", repltok); +#if DEFAULT_BACKEND_FLUSH_AFTER > 0 + snprintf(repltok, sizeof(repltok), "#backend_flush_after = %dkB", + DEFAULT_BACKEND_FLUSH_AFTER * (BLCKSZ / 1024)); + conflines = replace_token(conflines, "#backend_flush_after = 0", + repltok); +#endif + +#if DEFAULT_BGWRITER_FLUSH_AFTER > 0 + snprintf(repltok, sizeof(repltok), "#bgwriter_flush_after = %dkB", + DEFAULT_BGWRITER_FLUSH_AFTER * (BLCKSZ / 1024)); + conflines = replace_token(conflines, "#bgwriter_flush_after = 0", + repltok); +#endif + +#if DEFAULT_CHECKPOINT_FLUSH_AFTER > 0 + snprintf(repltok, sizeof(repltok), "#checkpoint_flush_after = %dkB", + DEFAULT_CHECKPOINT_FLUSH_AFTER * (BLCKSZ / 1024)); + conflines = replace_token(conflines, "#checkpoint_flush_after = 0", + repltok); +#endif + #ifndef USE_PREFETCH conflines = replace_token(conflines, "#effective_io_concurrency = 1", -- cgit v1.2.3