Skip to content

Commit 3684a53

Browse files
committed
I added a result set to START_STREAMING command, but neglected walreceiver.
The patch to allow pg_receivexlog to switch timeline added a result set after copy has ended in START_STREAMING command, to return the next timeline's ID to the client. But walreceived didn't get the memo, and threw an error on the unexpected result set. Fix.
1 parent 279628a commit 3684a53

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/backend/replication/libpqwalreceiver/libpqwalreceiver.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,17 +215,27 @@ libpqrcv_endstreaming(void)
215215

216216
while ((res = PQgetResult(streamConn)) != NULL)
217217
{
218-
if (PQresultStatus(res) != PGRES_COMMAND_OK)
219-
ereport(ERROR,
220-
(errmsg("error reading result of streaming command: %s",
221-
PQerrorMessage(streamConn))));
222218
/*
219+
* After Copy, if the streaming ended because we reached end of the
220+
* timeline, server sends one result set with the next timeline's ID.
221+
* We don't need it, so just slurp and ignore it.
222+
*
223223
* If we had not yet received CopyDone from the backend, PGRES_COPY_IN
224224
* is also possible. However, at the moment this function is only
225225
* called after receiving CopyDone from the backend - the walreceiver
226226
* never terminates replication on its own initiative.
227227
*/
228-
228+
switch (PQresultStatus(res))
229+
{
230+
case PGRES_COMMAND_OK:
231+
case PGRES_TUPLES_OK:
232+
break;
233+
234+
default:
235+
ereport(ERROR,
236+
(errmsg("error reading result of streaming command: %s",
237+
PQerrorMessage(streamConn))));
238+
}
229239
PQclear(res);
230240
}
231241
}

src/backend/replication/walreceiver.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,9 @@ WalReceiverMain(void)
431431
{
432432
ereport(LOG,
433433
(errmsg("replication terminated by primary server"),
434-
errdetail("End of WAL reached on timeline %u", startpointTLI)));
434+
errdetail("End of WAL reached on timeline %u at %X/%X",
435+
startpointTLI,
436+
(uint32) (LogstreamResult.Write >> 32), (uint32) LogstreamResult.Write)));
435437
endofwal = true;
436438
break;
437439
}

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