Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5fd56b9

Browse files
committed
Again report a useful error message when walreceiver's connection closes.
Since7c4f524 (merged in v10), a shutdown master is reported as FATAL: unexpected result after CommandComplete: server closed the connection unexpectedlyby walsender. It used to be LOG: replication terminated by primary server FATAL: could not send end-of-streaming message to primary: no COPY in progresswhile the old message clearly is not perfect, it's definitely betterthan what's reported now.The change comes from the attempt to handle finished COPYs withouterroring out, needed for the new logical replication, which wasn'tneeded before.There's probably better ways to handle this, but for now justexplicitly check for a closed connection.Author: Petr JelinekReviewed-By: Andres FreundDiscussion:https://postgr.es/m/f7c7dd08-855c-e4ed-41f4-d064a6c0665a@2ndquadrant.comBackpatch: -
1 parent5c4109f commit5fd56b9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

‎src/backend/replication/libpqwalreceiver/libpqwalreceiver.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,12 +682,25 @@ libpqrcv_receive(WalReceiverConn *conn, char **buffer,
682682
{
683683
PQclear(res);
684684

685-
/* Verify that there are no more results */
685+
/* Verify that there are no more results. */
686686
res=PQgetResult(conn->streamConn);
687687
if (res!=NULL)
688+
{
689+
PQclear(res);
690+
691+
/*
692+
* If the other side closed the connection orderly (otherwise
693+
* we'd seen an error, or PGRES_COPY_IN) don't report an error
694+
* here, but let callers deal with it.
695+
*/
696+
if (PQstatus(conn->streamConn)==CONNECTION_BAD)
697+
return-1;
698+
688699
ereport(ERROR,
689700
(errmsg("unexpected result after CommandComplete: %s",
690701
PQerrorMessage(conn->streamConn))));
702+
}
703+
691704
return-1;
692705
}
693706
elseif (PQresultStatus(res)==PGRES_COPY_IN)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp