From af8f42f2b60030b9847b19b9c26cd8c36815e9e1 Mon Sep 17 00:00:00 2001 From: Bharath Rupireddy Date: Sat, 10 Oct 2026 19:34:31 +0000 Subject: [PATCH] Disable opportunistic WAL buffer page initialization in WAL writer. This commit disables the WAL writer's opportunistic WAL buffer page initialization and forces WAL buffers to be 2GB, so that most of the WAL is available in the WAL buffers for readers. For testing purposes only. --- src/backend/access/transam/xlog.c | 6 +++++- src/test/recovery/t/049_wait_for_lsn.pl | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 8636ad9ab2c..50e9c3e2c3c 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -3201,7 +3201,7 @@ XLogBackgroundFlush(void) * Great, done. To take some work off the critical path, try to initialize * as many of the no-longer-needed WAL buffers for future use as we can. */ - AdvanceXLInsertBuffer(InvalidXLogRecPtr, insertTLI, true); + AdvanceXLInsertBuffer(InvalidXLogRecPtr, insertTLI, false); /* * If we determined that we need to write data, but somebody else @@ -5265,6 +5265,10 @@ XLOGChooseNumBuffers(void) bool check_wal_buffers(int *newval, void **extra, GucSource source) { + /* TRACEME: ignore the configured value and force 2GB */ + *newval = 2 * 1024 * (1024 * 1024 / XLOG_BLCKSZ); + return true; + /* * -1 indicates a request for auto-tune. */ diff --git a/src/test/recovery/t/049_wait_for_lsn.pl b/src/test/recovery/t/049_wait_for_lsn.pl index 0fe5b9c6f67..9f63b437fbe 100644 --- a/src/test/recovery/t/049_wait_for_lsn.pl +++ b/src/test/recovery/t/049_wait_for_lsn.pl @@ -8,6 +8,9 @@ use PostgreSQL::Test::Cluster; use PostgreSQL::Test::Utils; use Test::More; +# TRACEME: this test needs a small wal_buffers, skip it while it is forced. +plan skip_all => 'skipped while wal_buffers is forced'; + # Helper functions to control walreceiver for testing wait conditions. # These allow us to stop WAL streaming so waiters block, then resume it. my $saved_primary_conninfo; -- 2.47.3