diff options
author | Jeff Davis <jdavis@postgresql.org> | 2020-12-14 23:48:04 -0800 |
---|---|---|
committer | Jeff Davis <jdavis@postgresql.org> | 2020-12-14 23:48:04 -0800 |
commit | 706d84fe701ef9a8a5b04d2df013e29ea3f7ca74 (patch) | |
tree | ed227b4d8d84f2ec3faecee45aed982f4332f4e0 /src | |
parent | 8e456b8e597ed944eca7c24d6613ebff94aacb0b (diff) | |
download | postgresql-706d84fe701ef9a8a5b04d2df013e29ea3f7ca74.tar.gz postgresql-706d84fe701ef9a8a5b04d2df013e29ea3f7ca74.zip |
Revert "Cannot use WL_SOCKET_WRITEABLE without WL_SOCKET_READABLE."
This reverts commit 3a9e64aa0d96c8ffb6c682b082d0f72b1d373327.
Commit 4bad60e3 fixed the root of the problem that 3a9e64aa 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
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/replication/walsender.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index 02807544721..81031714596 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -1609,7 +1609,12 @@ ProcessRepliesIfAny(void) last_processing = GetCurrentTimestamp(); - for (;;) + /* + * If we already received a CopyDone from the frontend, any subsequent + * message is the beginning of a new command, and should be processed in + * the main processing loop. + */ + while (!streamingDoneReceiving) { pq_startmsgread(); r = pq_getbyte_if_available(&firstchar); @@ -1638,19 +1643,6 @@ ProcessRepliesIfAny(void) proc_exit(0); } - /* - * If we already received a CopyDone from the frontend, the frontend - * should not send us anything until we've closed our end of the COPY. - * XXX: In theory, the frontend could already send the next command - * before receiving the CopyDone, but libpq doesn't currently allow - * that. - */ - if (streamingDoneReceiving && firstchar != 'X') - ereport(FATAL, - (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg("unexpected standby message type \"%c\", after receiving CopyDone", - firstchar))); - /* Handle the very limited subset of commands expected in this phase */ switch (firstchar) { @@ -2251,8 +2243,10 @@ WalSndLoop(WalSndSendDataCallback send_data) long sleeptime; int wakeEvents; - wakeEvents = WL_LATCH_SET | WL_EXIT_ON_PM_DEATH | WL_TIMEOUT | - WL_SOCKET_READABLE; + wakeEvents = WL_LATCH_SET | WL_EXIT_ON_PM_DEATH | WL_TIMEOUT; + + if (!streamingDoneReceiving) + wakeEvents |= WL_SOCKET_READABLE; /* * Use fresh timestamp, not last_processed, to reduce the chance |