Hi Stepan,

Thanks for updating v3.

V3 skips the final CopyDone, but after COPY 0 both receivers leave the
inner receive loop and can try to send feedback before reaching that
check(WalReceiverMain -> XLogWalRcvSendReply,  LogicalRepApplyLoop ->
send_feedback). If feedback is due, the send can fail with no COPY in
progress. We could add copyEnded to libpqrcv_send to guard it, though
the callers could still mark the feedback as sent for skipping..

For HEAD, I wonder if it would be clearer for walrcv_receive() to
return two distinct values when the stream ends. With two return
values, the function signature is intact and both callers would keep
the existing handshake and send CopyDone after PGRES_COPY_IN. After
PGRES_COMMAND_OK, the two could skip further sends and finish their
local cleanup. This seems to change more and touch both loops, so I
see it as an option for HEAD.

Additionally,

PQstatus(conn->streamConn) == CONNECTION_BAD

Do we need this check in libpqrcv_endstreaming()?
copyEnded already covers COPY 0. If it is false, the check could turn
an unexpected disconnect into a clean exit. Is there a caller path
that needs it?


--
Regards,
Xuneng Zhou
HighGo Software Co., Ltd.


Reply via email to