walwriter: Separate sleep from delay.
authorAndres Freund <andres@anarazel.de>
Mon, 25 May 2020 10:02:56 +0000 (03:02 -0700)
committerAndres Freund <andres@anarazel.de>
Mon, 11 Jan 2021 23:09:14 +0000 (15:09 -0800)
We should probably instead wake walwriter when wal_writer_flush_after
has passed, even if wal_writer_delay wouldn't yet trigger.

Author:
Reviewed-By:
Discussion: https://postgr.es/m/
Backpatch:

src/backend/postmaster/walwriter.c
src/backend/utils/misc/guc.c
src/include/postmaster/walwriter.h

index 959004b828b8def607a804418fee2266851233ca..5f36796fcd677a48fb36a0ac21105f6054b81046 100644 (file)
@@ -68,6 +68,7 @@
  * GUC parameters
  */
 int            WalWriterDelay = 200;
+int            WalWriterSleep = 200;
 int            WalWriterFlushAfter = 128;
 
 /*
@@ -261,9 +262,9 @@ WalWriterMain(void)
         * sleep time so as to reduce the server's idle power consumption.
         */
        if (left_till_hibernate > 0)
-           cur_timeout = WalWriterDelay;   /* in ms */
+           cur_timeout = WalWriterSleep;   /* in ms */
        else
-           cur_timeout = WalWriterDelay * HIBERNATE_FACTOR;
+           cur_timeout = WalWriterSleep * HIBERNATE_FACTOR;
 
        (void) WaitLatch(MyLatch,
                         WL_LATCH_SET | WL_TIMEOUT | WL_EXIT_ON_PM_DEATH,
index 17579eeaca9c6a0851a4fd2062266b14c72dc0fe..6e55fd0e5deeac24bc7cbe62ffef9451b5414707 100644 (file)
@@ -2752,6 +2752,17 @@ static struct config_int ConfigureNamesInt[] =
        NULL, NULL, NULL
    },
 
+   {
+       {"wal_writer_sleep", PGC_SIGHUP, WAL_SETTINGS,
+           gettext_noop("How often WAL writer wakes up."),
+           NULL,
+           GUC_UNIT_MS
+       },
+       &WalWriterSleep,
+       200, 1, 10000,
+       NULL, NULL, NULL
+   },
+
    {
        {"wal_writer_flush_after", PGC_SIGHUP, WAL_SETTINGS,
            gettext_noop("Amount of WAL written out by WAL writer that triggers a flush."),
index 3ccc332333c1452df9264e63a38248ecc367f161..a24ffd008f18f1f5f173e4502a32c77c3f490426 100644 (file)
@@ -14,6 +14,7 @@
 
 /* GUC options */
 extern int WalWriterDelay;
+extern int WalWriterSleep;
 extern int WalWriterFlushAfter;
 
 extern void WalWriterMain(void) pg_attribute_noreturn();