aboutsummaryrefslogtreecommitdiff
path: root/src/backend/replication/walsender.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/replication/walsender.c')
-rw-r--r--src/backend/replication/walsender.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index d60026dfd1a..c83ff3b5732 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -1068,6 +1068,19 @@ StartLogicalReplication(StartReplicationCmd *cmd)
got_STOPPING = true;
}
+ /*
+ * Create our decoding context, making it start at the previously ack'ed
+ * position.
+ *
+ * Do this before sending CopyBoth, so that any errors are reported early.
+ */
+ logical_decoding_ctx =
+ CreateDecodingContext(cmd->startpoint, cmd->options, false,
+ logical_read_xlog_page,
+ WalSndPrepareWrite, WalSndWriteData,
+ WalSndUpdateProgress);
+
+
WalSndSetState(WALSNDSTATE_CATCHUP);
/* Send a CopyBothResponse message, and start streaming */
@@ -1077,16 +1090,6 @@ StartLogicalReplication(StartReplicationCmd *cmd)
pq_endmessage(&buf);
pq_flush();
- /*
- * Initialize position to the last ack'ed one, then the xlog records begin
- * to be shipped from that position.
- */
- logical_decoding_ctx = CreateDecodingContext(cmd->startpoint, cmd->options,
- false,
- logical_read_xlog_page,
- WalSndPrepareWrite,
- WalSndWriteData,
- WalSndUpdateProgress);
/* Start reading WAL from the oldest required WAL. */
logical_startptr = MyReplicationSlot->data.restart_lsn;