Skip to content

Commit fde5f13

Browse files
committed
Revert "Cannot use WL_SOCKET_WRITEABLE without WL_SOCKET_READABLE."
This reverts commit 3a9e64a. Commit 4bad60e fixed the root of the problem that 3a9e64a worked around. This enables proper pipelining of commands after terminating replication, eliminating an undocumented limitation. Discussion: https://postgr.es/m/3d57bc29-4459-578b-79cb-7641baf53c57%40iki.fi Backpatch-through: 9.5
1 parent 787d06a commit fde5f13

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

src/backend/replication/walsender.c

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,7 +1707,12 @@ ProcessRepliesIfAny(void)
17071707

17081708
last_processing = GetCurrentTimestamp();
17091709

1710-
for (;;)
1710+
/*
1711+
* If we already received a CopyDone from the frontend, any subsequent
1712+
* message is the beginning of a new command, and should be processed in
1713+
* the main processing loop.
1714+
*/
1715+
while (!streamingDoneReceiving)
17111716
{
17121717
pq_startmsgread();
17131718
r = pq_getbyte_if_available(&firstchar);
@@ -1736,19 +1741,6 @@ ProcessRepliesIfAny(void)
17361741
proc_exit(0);
17371742
}
17381743

1739-
/*
1740-
* If we already received a CopyDone from the frontend, the frontend
1741-
* should not send us anything until we've closed our end of the COPY.
1742-
* XXX: In theory, the frontend could already send the next command
1743-
* before receiving the CopyDone, but libpq doesn't currently allow
1744-
* that.
1745-
*/
1746-
if (streamingDoneReceiving && firstchar != 'X')
1747-
ereport(FATAL,
1748-
(errcode(ERRCODE_PROTOCOL_VIOLATION),
1749-
errmsg("unexpected standby message type \"%c\", after receiving CopyDone",
1750-
firstchar)));
1751-
17521744
/* Handle the very limited subset of commands expected in this phase */
17531745
switch (firstchar)
17541746
{
@@ -2349,8 +2341,10 @@ WalSndLoop(WalSndSendDataCallback send_data)
23492341
long sleeptime;
23502342
int wakeEvents;
23512343

2352-
wakeEvents = WL_LATCH_SET | WL_EXIT_ON_PM_DEATH | WL_TIMEOUT |
2353-
WL_SOCKET_READABLE;
2344+
wakeEvents = WL_LATCH_SET | WL_EXIT_ON_PM_DEATH | WL_TIMEOUT;
2345+
2346+
if (!streamingDoneReceiving)
2347+
wakeEvents |= WL_SOCKET_READABLE;
23542348

23552349
/*
23562350
* Use fresh timestamp, not last_processing, to reduce the chance

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