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