Remove useless code from CreateReplicationSlot.
authorRobert Haas <rhaas@postgresql.org>
Mon, 25 Oct 2021 14:57:12 +0000 (10:57 -0400)
committerRobert Haas <rhaas@postgresql.org>
Mon, 25 Oct 2021 14:57:12 +0000 (10:57 -0400)
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.

Discussion: http://postgr.es/m/CA+TgmobSWzacEs+r6C-7DrOPDHoDar4i9gzxB3SCBr5qjnLmVQ@mail.gmail.com

src/backend/replication/walsender.c

index d8f5f113c02ef341a459cecf02c0d9c018ecd82a..d9ab6d6de241a930ee3af79e28e1884b0e816c7b 100644 (file)
@@ -1042,10 +1042,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,