Skip to content

Commit 4934062

Browse files
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
1 parent bd08223 commit 4934062

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/bin/pg_basebackup/receivelog.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -503,26 +503,28 @@ ReceiveXlogStream(PGconn *conn, StreamCtl *stream)
503503
if (!CheckServerVersionForStreaming(conn))
504504
return false;
505505

506+
/*
507+
* Decide whether we want to report the flush position. If we report
508+
* the flush position, the primary will know what WAL we'll
509+
* possibly re-request, and it can then remove older WAL safely.
510+
* We must always do that when we are using slots.
511+
*
512+
* Reporting the flush position makes one eligible as a synchronous
513+
* replica. People shouldn't include generic names in
514+
* synchronous_standby_names, but we've protected them against it so
515+
* far, so let's continue to do so unless specifically requested.
516+
*/
506517
if (replication_slot != NULL)
507518
{
508-
/*
509-
* Report the flush position, so the primary can know what WAL we'll
510-
* possibly re-request, and remove older WAL safely.
511-
*
512-
* We only report it when a slot has explicitly been used, because
513-
* reporting the flush position makes one eligible as a synchronous
514-
* replica. People shouldn't include generic names in
515-
* synchronous_standby_names, but we've protected them against it so
516-
* far, so let's continue to do so in the situations when possible. If
517-
* they've got a slot, though, we need to report the flush position,
518-
* so that the master can remove WAL.
519-
*/
520519
reportFlushPosition = true;
521520
sprintf(slotcmd, "SLOT \"%s\" ", replication_slot);
522521
}
523522
else
524523
{
525-
reportFlushPosition = false;
524+
if (stream->synchronous)
525+
reportFlushPosition = true;
526+
else
527+
reportFlushPosition = false;
526528
slotcmd[0] = 0;
527529
}
528530

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy