From 4e9821b6fac5042e872d5397f711a67984b165f8 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Wed, 14 Oct 2020 20:12:26 -0300 Subject: Restore replication protocol's duplicate command tags I removed the duplicate command tags for START_REPLICATION inadvertently in commit 07082b08cc5d, but the replication protocol requires them. The fact that the replication protocol was broken was not noticed because all our test cases use an optimized code path that exits early, failing to verify that the behavior is correct for non-optimized cases. Put them back. Also document this protocol quirk. Add a test case that shows the failure. It might still succeed even without the patch when run on a fast enough server, but it suffices to show the bug in enough cases that it would be noticed in buildfarm. Author: Álvaro Herrera Reported-by: Henry Hinze Reviewed-by: Petr Jelínek Discussion: https://postgr.es/m/16643-eaadeb2a1a58d28c@postgresql.org --- src/backend/replication/logical/worker.c | 1 - src/backend/replication/walsender.c | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/backend') diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index 4f32dc74c86..640409b757f 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -3071,7 +3071,6 @@ ApplyWorkerMain(Datum main_arg) * does some initializations on the upstream so let's still call it. */ (void) walrcv_identify_system(wrconn, &startpointTLI); - } /* diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index 7c9d1b67dfb..df27e847617 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -1656,7 +1656,8 @@ exec_replication_command(const char *cmd_string) else StartLogicalReplication(cmd); - /* callees already sent their own completion message */ + /* dupe, but necessary per libpqrcv_endstreaming */ + EndReplicationCommand(cmdtag); Assert(xlogreader != NULL); break; -- cgit v1.2.3