From 95555ba2f06fe71ffc16a3222253694b9ecc3875 Mon Sep 17 00:00:00 2001 From: souravbiswassanto Date: Tue, 28 Jul 2026 16:21:11 +0600 Subject: [PATCH] =?UTF-8?q?Enable=20hot=5Fstandby=20when=20using=20Replica?= =?UTF-8?q?tionSlot=20WAL=20limit=20policy=20(v17=E2=80=93v18)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When WAL_LIMIT_POLICY is set to ReplicationSlot, PostgreSQL requires hot_standby to be enabled on standbys to prevent startup failures with existing logical replication slots. This fixes the error: "logical replication slot exists on the standby, but hot_standby = off" Updated both fresh initialization (run.sh) and warm standby recovery (warm_stanby.sh) scripts to respect WAL_LIMIT_POLICY in addition to the STANDBY variable when configuring hot_standby. Fixes #66 Signed-off-by: souravbiswassanto --- role_scripts/17/standby/run.sh | 2 +- role_scripts/17/standby/warm_stanby.sh | 6 +++++- role_scripts/18/standby/run.sh | 2 +- role_scripts/18/standby/warm_stanby.sh | 6 +++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/role_scripts/17/standby/run.sh b/role_scripts/17/standby/run.sh index ff5673a..725a5b9 100755 --- a/role_scripts/17/standby/run.sh +++ b/role_scripts/17/standby/run.sh @@ -163,7 +163,7 @@ fi echo "shared_preload_libraries = 'pg_stat_statements'" >>/tmp/postgresql.conf -if [ "$STANDBY" == "hot" ]; then +if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]] || [ "$STANDBY" == "hot" ]; then echo "hot_standby = on" >>/tmp/postgresql.conf else echo "hot_standby = off" >>/tmp/postgresql.conf diff --git a/role_scripts/17/standby/warm_stanby.sh b/role_scripts/17/standby/warm_stanby.sh index a1eff58..a9c81d1 100755 --- a/role_scripts/17/standby/warm_stanby.sh +++ b/role_scripts/17/standby/warm_stanby.sh @@ -37,7 +37,11 @@ echo "max_replication_slots = 90" >>/tmp/postgresql.conf echo "archive_mode = always" >>/tmp/postgresql.conf echo "archive_command = '/bin/true'" >>/tmp/postgresql.conf -echo "hot_standby = off" >>/tmp/postgresql.conf +if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]]; then + echo "hot_standby = on" >>/tmp/postgresql.conf +else + echo "hot_standby = off" >>/tmp/postgresql.conf +fi echo "shared_preload_libraries = 'pg_stat_statements'" >>/tmp/postgresql.conf diff --git a/role_scripts/18/standby/run.sh b/role_scripts/18/standby/run.sh index ff5673a..725a5b9 100755 --- a/role_scripts/18/standby/run.sh +++ b/role_scripts/18/standby/run.sh @@ -163,7 +163,7 @@ fi echo "shared_preload_libraries = 'pg_stat_statements'" >>/tmp/postgresql.conf -if [ "$STANDBY" == "hot" ]; then +if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]] || [ "$STANDBY" == "hot" ]; then echo "hot_standby = on" >>/tmp/postgresql.conf else echo "hot_standby = off" >>/tmp/postgresql.conf diff --git a/role_scripts/18/standby/warm_stanby.sh b/role_scripts/18/standby/warm_stanby.sh index a1eff58..a9c81d1 100755 --- a/role_scripts/18/standby/warm_stanby.sh +++ b/role_scripts/18/standby/warm_stanby.sh @@ -37,7 +37,11 @@ echo "max_replication_slots = 90" >>/tmp/postgresql.conf echo "archive_mode = always" >>/tmp/postgresql.conf echo "archive_command = '/bin/true'" >>/tmp/postgresql.conf -echo "hot_standby = off" >>/tmp/postgresql.conf +if [[ "$WAL_LIMIT_POLICY" == "ReplicationSlot" ]]; then + echo "hot_standby = on" >>/tmp/postgresql.conf +else + echo "hot_standby = off" >>/tmp/postgresql.conf +fi echo "shared_preload_libraries = 'pg_stat_statements'" >>/tmp/postgresql.conf