Re: libpq changes for synchronous replication - Mailing list pgsql-hackers

From Boszormenyi Zoltan
Subject Re: libpq changes for synchronous replication
Date
Msg-id 4C986AEC.6010903@cybertec.at
Whole thread Raw
In response to Re: libpq changes for synchronous replication  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,

Tom Lane írta:
> Heikki Linnakangas <heikki.linnakangas@enterprisedb.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/



pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Re: Configuring synchronous replication
Next
From: Boszormenyi Zoltan
Date:
Subject: Re: libpq changes for synchronous replication