v3-0001-Disallow-server-start-with-sync_replication_slots.patch

application/octet-stream

Filename: v3-0001-Disallow-server-start-with-sync_replication_slots.patch
Type: application/octet-stream
Part: 0
Message: Re: Unexpected Standby Shutdown on sync_replication_slots change

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v3-0001
Subject: Disallow server start with sync_replication_slots = on and wal_level < logical.
File+
src/backend/postmaster/postmaster.c 3 0
From 013de74075b74a8919a3adcd6596b85bfb20da40 Mon Sep 17 00:00:00 2001
From: Fujii Masao <fujii@postgresql.org>
Date: Sun, 3 Aug 2025 11:24:51 +0900
Subject: [PATCH v3] Disallow server start with sync_replication_slots = on and
 wal_level < logical.

Replication slot synchronization (sync_replication_slots = on)
requires wal_level to be logical. This commit prevents the server
from starting if sync_replication_slots is enabled but wal_level
is set to minimal or replica.

Failing early during startup helps users catch invalid configurations
immediately, which is important because changing wal_level requires
a server restart.
---
 src/backend/postmaster/postmaster.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index e01d9f0cfe8..e1d643b013d 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -854,6 +854,9 @@ PostmasterMain(int argc, char *argv[])
 	if (summarize_wal && wal_level == WAL_LEVEL_MINIMAL)
 		ereport(ERROR,
 				(errmsg("WAL cannot be summarized when \"wal_level\" is \"minimal\"")));
+	if (sync_replication_slots && wal_level < WAL_LEVEL_LOGICAL)
+		ereport(ERROR,
+				(errmsg("replication slot synchronization (\"sync_replication_slots\" = on) requires \"wal_level\" >= \"logical\"")));
 
 	/*
 	 * Other one-time internal sanity checks can go here, if they are fast.
-- 
2.50.1