v24-0013-Consider-temporary-slot-to-check-max_replication.patch

application/octet-stream

Filename: v24-0013-Consider-temporary-slot-to-check-max_replication.patch
Type: application/octet-stream
Part: 12
Message: RE: speed up a logical replica setup

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 v24-0013
Subject: Consider temporary slot to check max_replication_slots in primary
File+
src/bin/pg_basebackup/pg_createsubscriber.c 5 4
From 2de7b6ef4f74170b9f593b9fbe1e7524f4cf76da Mon Sep 17 00:00:00 2001
From: Shlok Kyal <shlok.kyal.oss@gmail.com>
Date: Tue, 20 Feb 2024 14:53:55 +0530
Subject: [PATCH v24 13/18] Consider temporary slot to check
 max_replication_slots in primary

While checking for max_replication_slots in primary we should consider
the temporary slot as well.
---
 src/bin/pg_basebackup/pg_createsubscriber.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index 26ce91f58b..4a28dfb81c 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -698,7 +698,8 @@ check_publisher(LogicalRepInfo *dbinfo)
 	 * we should check it to make sure it won't fail.
 	 *
 	 * - wal_level = logical
-	 * - max_replication_slots >= current + number of dbs to be converted
+	 * - max_replication_slots >= current + number of dbs to be converted +
+	 * 							  temporary slot to be created
 	 * - max_wal_senders >= current + number of dbs to be converted
 	 * -----------------------------------------------------------------------
 	 */
@@ -786,12 +787,12 @@ check_publisher(LogicalRepInfo *dbinfo)
 		return false;
 	}
 
-	if (max_repslots - cur_repslots < num_dbs)
+	if (max_repslots - cur_repslots < num_dbs + 1)
 	{
 		pg_log_error("publisher requires %d replication slots, but only %d remain",
-					 num_dbs, max_repslots - cur_repslots);
+					 num_dbs + 1, max_repslots - cur_repslots);
 		pg_log_error_hint("Consider increasing max_replication_slots to at least %d.",
-						  cur_repslots + num_dbs);
+						  cur_repslots + num_dbs + 1);
 		return false;
 	}
 
-- 
2.43.0