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

Commit 706d84f

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 8e456b8 commit 706d84f

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
@@ -1609,7 +1609,12 @@ ProcessRepliesIfAny(void)
16091609

16101610
last_processing = GetCurrentTimestamp();
16111611

1612-
for (;;)
1612+
/*
1613+
* If we already received a CopyDone from the frontend, any subsequent
1614+
* message is the beginning of a new command, and should be processed in
1615+
* the main processing loop.
1616+
*/
1617+
while (!streamingDoneReceiving)
16131618
{
16141619
pq_startmsgread();
16151620
r = pq_getbyte_if_available(&firstchar);
@@ -1638,19 +1643,6 @@ ProcessRepliesIfAny(void)
16381643
proc_exit(0);
16391644
}
16401645

1641-
/*
1642-
* If we already received a CopyDone from the frontend, the frontend
1643-
* should not send us anything until we've closed our end of the COPY.
1644-
* XXX: In theory, the frontend could already send the next command
1645-
* before receiving the CopyDone, but libpq doesn't currently allow
1646-
* that.
1647-
*/
1648-
if (streamingDoneReceiving && firstchar != 'X')
1649-
ereport(FATAL,
1650-
(errcode(ERRCODE_PROTOCOL_VIOLATION),
1651-
errmsg("unexpected standby message type \"%c\", after receiving CopyDone",
1652-
firstchar)));
1653-
16541646
/* Handle the very limited subset of commands expected in this phase */
16551647
switch (firstchar)
16561648
{
@@ -2251,8 +2243,10 @@ WalSndLoop(WalSndSendDataCallback send_data)
22512243
long sleeptime;
22522244
int wakeEvents;
22532245

2254-
wakeEvents = WL_LATCH_SET | WL_EXIT_ON_PM_DEATH | WL_TIMEOUT |
2255-
WL_SOCKET_READABLE;
2246+
wakeEvents = WL_LATCH_SET | WL_EXIT_ON_PM_DEATH | WL_TIMEOUT;
2247+
2248+
if (!streamingDoneReceiving)
2249+
wakeEvents |= WL_SOCKET_READABLE;
22562250

22572251
/*
22582252
* Use fresh timestamp, not last_processed, to reduce the chance

0 commit comments

Comments
 (0)