Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c3e7c24

Browse files
committed
libpq: Notice errors a backend may have sent just before dying.
At least since the introduction of Hot Standby, the backend has sometimes sent fatal errors even when no client query was in progress, assuming that the client would receive it. However, pqHandleSendFailure was not in sync with this assumption, and only tries to catch notices and notifies. Add a parseInput call to the loop there to fix. Andres Freund suggested the fix. Comments are by me. Reviewed by Michael Paquier.
1 parent ac1d794 commit c3e7c24

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/interfaces/libpq/fe-exec.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -1553,25 +1553,25 @@ PQsendQueryGuts(PGconn *conn,
15531553
/*
15541554
* pqHandleSendFailure: try to clean up after failure to send command.
15551555
*
1556-
* Primarily, what we want to accomplish here is to process an async
1557-
* NOTICE message that the backend might have sent just before it died.
1556+
* Primarily, what we want to accomplish here is to process any messages that
1557+
* the backend might have sent just before it died.
15581558
*
15591559
* NOTE: this routine should only be called in PGASYNC_IDLE state.
15601560
*/
15611561
void
15621562
pqHandleSendFailure(PGconn *conn)
15631563
{
15641564
/*
1565-
* Accept any available input data, ignoring errors. Note that if
1566-
* pqReadData decides the backend has closed the channel, it will close
1567-
* our side of the socket --- that's just what we want here.
1565+
* Accept and parse any available input data. Note that if pqReadData
1566+
* decides the backend has closed the channel, it will close our side of
1567+
* the socket --- that's just what we want here.
15681568
*/
15691569
while (pqReadData(conn) > 0)
1570-
/* loop until no more data readable */ ;
1570+
parseInput(conn);
15711571

15721572
/*
1573-
* Parse any available input messages. Since we are in PGASYNC_IDLE
1574-
* state, only NOTICE and NOTIFY messages will be eaten.
1573+
* Make one attempt to parse available input messages even if we read no
1574+
* data.
15751575
*/
15761576
parseInput(conn);
15771577
}

0 commit comments

Comments
 (0)