Skip to content
Snippets Groups Projects
Commit 216fd7fe authored by Simon Riggs's avatar Simon Riggs
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
parent 2802b02a
No related branches found
No related tags found
No related merge requests found
......@@ -503,25 +503,27 @@ ReceiveXlogStream(PGconn *conn, StreamCtl *stream)
if (!CheckServerVersionForStreaming(conn))
return false;
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.
* 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.
*
* We only report it when a slot has explicitly been used, because
* reporting the flush position makes one eligible as a synchronous
* 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.
* far, so let's continue to do so unless specifically requested.
*/
if (replication_slot != NULL)
{
reportFlushPosition = true;
sprintf(slotcmd, "SLOT \"%s\" ", replication_slot);
}
else
{
if (stream->synchronous)
reportFlushPosition = true;
else
reportFlushPosition = false;
slotcmd[0] = 0;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment