Re: Replication protocol doc fix

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Replication protocol doc fix
Date: 2021-06-16 21:15:35
Message-ID: 6fd5e90a90e25e8b420d183152b708ab23510201.camel@j-davis.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 2021-06-14 at 10:51 -0400, Robert Haas wrote:
> but if
> > > you use the extended query protocol, then the result is a
> > > hopeless
> > > mess, because the protocol is badly designed:
> > >

After looking in more detail, I think I understand a bit better.
Clients don't differentiate between:

* A normal command, where you know that you've sent everything that you
will send. In this case, the client needs to send the Sync message in
order to get the ReadyForQuery message.

* A command that initiates CopyIn/CopyBoth, where you are going to send
more data after the command. In this case, sending the Sync eagerly is
wrong, and you can't pipeline more queries in the middle of
CopyIn/CopyBoth mode. Instead, the client should send Sync after
receiving an ErrorResponse, or after sending a CopyDone/CopyFail
(right?).

One thing I don't fully understand is what would happen if the client
issued the Sync as the *first* message in an extended-protocol series.

> > > But I think you're correct in saying that the discard-until-Sync
> > > behavior only happens if the extended query protocol is used, so
> > > I
> > > agree that the current text is wrong.
> >
> > Should we just document how CopyBoth works with the simple query
> > protocol, or should we make it match the CopyIn docs?
>
> I think it would make sense to make it match the CopyIn docs.
> Possibly
> the CopyOut docs should be made more similar as well.

I attached a doc patch that hopefully clarifies this point as well as
the weirdness around CopyIn/CopyBoth and the extended protocol. I
reorganized the sections, as well.

Regards,
Jeff Davis

Attachment Content-Type Size
copy-flow.diff text/x-patch 9.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2021-06-16 21:25:42 Re: Replication protocol doc fix
Previous Message Tom Lane 2021-06-16 21:13:16 Re: Python 3.10 breaks regression tests with traceback changes