Re: libpq changes for synchronous replication

From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: libpq changes for synchronous replication
Date: 2010-09-21 08:21:00
Message-ID: 4C986AEC.6010903@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Tom Lane írta:
> Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> writes:
>
>> It doesn't feel right to always accept PQputCopyData in COPY OUT mode,
>> though. IMHO there should be a new COPY IN+OUT mode.
>>
>
> Yeah, I was going to make the same complaint. Breaking basic
> error-checking functionality in libpq is not very acceptable.
>

if you looked at my sync replication patch, basically I only added
the checking in PQputCopyData that it's allowed in COPY IN mode
iff the pgconn was set up for replication. I introduced a new libpq
function PQsetDuplexCopy() at the time but Fujii's idea was that
it can be omitted and use the conn->replication pointer instead.
It seems he forgot about it. Something like this might work:

if (conn->asyncStatus != PGASYNC_COPY_IN &&
!(conn->asyncStatus == PGASYNC_COPY_OUT &&
conn->replication && conn->replication[0]))
...

This way the original error checking is still in place and only
a replication client can do a duplex COPY.

>> It should be pretty safe to add a CopyInOutResponse message to the
>> protocol without a protocol version bump. Thoughts on that?
>>
>
> Not if it's something that an existing application might see. If
> it can only happen in replication mode it's OK.
>

My PQsetDuplexCopy() call was only usable for a replication client,
it resulted in an "unknown protocol message" for a regular client.
For a replication client, walsender sent an ack and libpq have set
the "duplex copy" flag so it allowed PQputCopyData while in
COPY OUT. I'd like a little comment from you whether it's a
good idea, or the above check is enough.

> Personally I think this demonstrates that piggybacking replication
> data transfer on the COPY protocol was a bad design to start with.
> It's probably time to split them apart.
>

Best regards,
Zoltán Böszörményi

--
----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de
http://www.postgresql.at/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Boszormenyi Zoltan 2010-09-21 08:21:50 Re: libpq changes for synchronous replication
Previous Message Fujii Masao 2010-09-21 07:58:25 Re: Configuring synchronous replication