Re: remote_apply for logical replication?

From: Petr Jelinek <petr(dot)jelinek(at)2ndquadrant(dot)com>
To: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: remote_apply for logical replication?
Date: 2017-01-21 15:06:55
Message-ID: f453caad-0396-1bdd-c5c1-5094371f4776@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 21/01/17 01:34, Thomas Munro wrote:
> Hi,
>
> In src/backend/replication/logical/worker.c:
>
> pq_sendbyte(reply_message, 'r');
> pq_sendint64(reply_message, recvpos); /* write */
> pq_sendint64(reply_message, flushpos); /* flush */
> pq_sendint64(reply_message, writepos); /* apply */
>
> Is 'writepos' really applied? Why do we report the merely received
> position as written?
>

Because we don't have intermediate steps in logical replication, writes
happen immediately and in whole transactions so whatever was received by
the time we send reply is already written (it might not necessarily be
that way forever so the code may become more complicated eventually).

> I haven't tried any of this stuff out yet so this may be a stupid
> question, but I'm wondering: should xinfo &
> XACT_COMPLETION_APPLY_FEEDBACK trigger logical replication to send a
> reply, so that synchronous_commit = remote_apply would work?
>

In fact everything is remote_apply in logical replication for same
reason described above. The differences can only happen when the
subscription is running with synchronous_commit = off where flush
position is behind. The xinfo & XACT_COMPLETION_APPLY_FEEDBACK does not
affect logical replication though as it does not have access to that
information (subscriber does not receive raw WAL and logical decoding
does not decode this).

--
Petr Jelinek http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Petr Jelinek 2017-01-21 15:18:22 Re: Checksums by default?
Previous Message Stephen Frost 2017-01-21 14:15:02 Re: Checksums by default?