Fix initdb's handling of min_wal_size and max_wal_size.
authorTom Lane <[email protected]>
Wed, 22 Mar 2023 20:37:41 +0000 (16:37 -0400)
committerTom Lane <[email protected]>
Wed, 22 Mar 2023 20:37:41 +0000 (16:37 -0400)
In commit 3e51b278d, I misinterpreted the coding in setup_config()
as setting min_wal_size and max_wal_size to compile-time-constant
values.  But it's not: there's a hidden dependency on --wal-segsize.
Therefore leaving these variables commented out is the wrong thing.
Per report from Andres Freund.

Discussion: https://postgr.es/m/20230322200751[email protected]

src/bin/initdb/initdb.c

index acc6412c139ff1ac8f459c7dc416239405ebab24..3c0bf5c0a893f6d913e66191d913f3c7d495cec5 100644 (file)
@@ -1279,6 +1279,13 @@ setup_config(void)
        conflines = replace_guc_value(conflines, "dynamic_shared_memory_type",
                                                                  dynamic_shared_memory_type, false);
 
+       /* Caution: these depend on wal_segment_size_mb, they're not constants */
+       conflines = replace_guc_value(conflines, "min_wal_size",
+                                                                 pretty_wal_size(DEFAULT_MIN_WAL_SEGS), false);
+
+       conflines = replace_guc_value(conflines, "max_wal_size",
+                                                                 pretty_wal_size(DEFAULT_MAX_WAL_SEGS), false);
+
        /*
         * Fix up various entries to match the true compile-time defaults.  Since
         * these are indeed defaults, keep the postgresql.conf lines commented.
@@ -1289,12 +1296,6 @@ setup_config(void)
        conflines = replace_guc_value(conflines, "port",
                                                                  DEF_PGPORT_STR, true);
 
-       conflines = replace_guc_value(conflines, "min_wal_size",
-                                                                 pretty_wal_size(DEFAULT_MIN_WAL_SEGS), true);
-
-       conflines = replace_guc_value(conflines, "max_wal_size",
-                                                                 pretty_wal_size(DEFAULT_MAX_WAL_SEGS), true);
-
 #if DEFAULT_BACKEND_FLUSH_AFTER > 0
        snprintf(repltok, sizeof(repltok), "%dkB",
                         DEFAULT_BACKEND_FLUSH_AFTER * (BLCKSZ / 1024));