From 5cc2f298b107014e38d2d7bfc3360e34351e8dba Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Thu, 21 Oct 2021 14:29:01 -0400 Subject: [PATCH] Remove useless code from CreateReplicationSlot. According to the comments, we initialize sendTimeLineIsHistoric and sendTimeLine here for the benefit of WalSndSegmentOpen. However, the only way that can happen is if logical_read_xlog_page calls WALRead. And since logical_read_xlog_page initializes the same global variables internally, we don't need to also do it here. These initializations have been here since replication slots were introduced in commit 858ec11858a914d4c380971985709b6d6b7dd6fc. They were certainly useless at that time, too, because logical decoding didn't yet exist then, and physical replication doesn't examine any WAL at the time of slot creation. I haven't checked all the intermediate versions, but I suspect there's no point at which this code ever did anything useful. To reduce future confusion, remove the code. Since there's no functional defect, no back-patch. --- src/backend/replication/walsender.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index b811a5c0ef..c8f61cfad0 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -943,10 +943,6 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd) parseCreateReplSlotOptions(cmd, &reserve_wal, &snapshot_action, &two_phase); - /* setup state for WalSndSegmentOpen */ - sendTimeLineIsHistoric = false; - sendTimeLine = ThisTimeLineID; - if (cmd->kind == REPLICATION_KIND_PHYSICAL) { ReplicationSlotCreate(cmd->slotname, false, -- 2.24.3 (Apple Git-128)