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

Commit3a9e64a

Browse files
committed
Cannot use WL_SOCKET_WRITEABLE without WL_SOCKET_READABLE.
In copy-out mode, the frontend should not send any messages until thebackend has finished streaming, by sending a CopyDone message. I'm not sureif it would be legal for the client to send a new query before receiving theCopyDone message from the backend, but trying to support that would requirebigger changes to the backend code structure.Fixes an assertion failure reported by Fujii Masao.
1 parent5ddf38f commit3a9e64a

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

‎src/backend/replication/walsender.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -674,12 +674,7 @@ ProcessRepliesIfAny(void)
674674
intr;
675675
boolreceived= false;
676676

677-
/*
678-
* If we already received a CopyDone from the frontend, any subsequent
679-
* message is the beginning of a new command, and should be processed in
680-
* the main processing loop.
681-
*/
682-
while (!streamingDoneReceiving)
677+
for (;;)
683678
{
684679
r=pq_getbyte_if_available(&firstchar);
685680
if (r<0)
@@ -696,6 +691,19 @@ ProcessRepliesIfAny(void)
696691
break;
697692
}
698693

694+
/*
695+
* If we already received a CopyDone from the frontend, the frontend
696+
* should not send us anything until we've closed our end of the COPY.
697+
* XXX: In theory, the frontend could already send the next command
698+
* before receiving the CopyDone, but libpq doesn't currently allow
699+
* that.
700+
*/
701+
if (streamingDoneReceiving&&firstchar!='X')
702+
ereport(FATAL,
703+
(errcode(ERRCODE_PROTOCOL_VIOLATION),
704+
errmsg("unexpected standby message type \"%c\", after receiving CopyDone",
705+
firstchar)));
706+
699707
/* Handle the very limited subset of commands expected in this phase */
700708
switch (firstchar)
701709
{
@@ -1048,10 +1056,8 @@ WalSndLoop(void)
10481056
longsleeptime=10000;/* 10 s */
10491057
intwakeEvents;
10501058

1051-
wakeEvents=WL_LATCH_SET |WL_POSTMASTER_DEATH |WL_TIMEOUT;
1052-
1053-
if (!streamingDoneReceiving)
1054-
wakeEvents |=WL_SOCKET_READABLE;
1059+
wakeEvents=WL_LATCH_SET |WL_POSTMASTER_DEATH |WL_TIMEOUT |
1060+
WL_SOCKET_READABLE;
10551061

10561062
if (pq_is_send_pending())
10571063
wakeEvents |=WL_SOCKET_WRITEABLE;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp