Re: FATAL: could not send end-of-streaming message to primary: no COPY in progress

From: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
To: Stepan Neretin <slpmcf(at)gmail(dot)com>
Cc: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Subject: Re: FATAL: could not send end-of-streaming message to primary: no COPY in progress
Date: 2026-11-22 07:01:20
Message-ID: CABPTF7XKzzC6VdO=sc3KCC676TsF77O5zzsoT1evCE6JWB27OQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tender Wang 2026-11-22 07:45:48 Fix stale source values in MERGE RETURNING after a cross-partition update
Previous Message vignesh C 2026-11-22 06:21:56 Re: [PATCH v1] Fix initial sync of zero-column published tables