diff options
author | Simon Riggs <simon@2ndQuadrant.com> | 2016-08-29 12:18:12 +0100 |
---|---|---|
committer | Simon Riggs <simon@2ndQuadrant.com> | 2016-08-29 12:18:12 +0100 |
commit | 216fd7fe77c693a9595bb7550de2927dde650218 (patch) | |
tree | 4b691882e695d0a63f8f54712fd7f37824417ac2 /src | |
parent | 2802b02a540c0f5bc2d11e801dc527d4240ed404 (diff) | |
download | postgresql-216fd7fe77c693a9595bb7550de2927dde650218.tar.gz postgresql-216fd7fe77c693a9595bb7550de2927dde650218.zip |
Fix pg_receivexlog --synchronous
Make pg_receivexlog work correctly with —-synchronous without slots
Backpatch to 9.5
Gabriele Bartolini, reviewed by Michael Paquier and Simon Riggs
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/pg_basebackup/receivelog.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c index 595213f0420..062730b6b43 100644 --- a/src/bin/pg_basebackup/receivelog.c +++ b/src/bin/pg_basebackup/receivelog.c @@ -503,26 +503,28 @@ ReceiveXlogStream(PGconn *conn, StreamCtl *stream) if (!CheckServerVersionForStreaming(conn)) return false; + /* + * Decide whether we want to report the flush position. If we report + * the flush position, the primary will know what WAL we'll + * possibly re-request, and it can then remove older WAL safely. + * We must always do that when we are using slots. + * + * Reporting the flush position makes one eligible as a synchronous + * replica. People shouldn't include generic names in + * synchronous_standby_names, but we've protected them against it so + * far, so let's continue to do so unless specifically requested. + */ if (replication_slot != NULL) { - /* - * Report the flush position, so the primary can know what WAL we'll - * possibly re-request, and remove older WAL safely. - * - * We only report it when a slot has explicitly been used, because - * reporting the flush position makes one eligible as a synchronous - * replica. People shouldn't include generic names in - * synchronous_standby_names, but we've protected them against it so - * far, so let's continue to do so in the situations when possible. If - * they've got a slot, though, we need to report the flush position, - * so that the master can remove WAL. - */ reportFlushPosition = true; sprintf(slotcmd, "SLOT \"%s\" ", replication_slot); } else { - reportFlushPosition = false; + if (stream->synchronous) + reportFlushPosition = true; + else + reportFlushPosition = false; slotcmd[0] = 0; } |