Re: [HACKERS] remote_apply for logical replication?

2017-01-21 Thread Thomas Munro
On Sun, Jan 22, 2017 at 4:06 AM, Petr Jelinek
 wrote:
> 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).

Ah.  Thanks for the explanation.  Very cool work, congratulations!

-- 
Thomas Munro
http://www.enterprisedb.com


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] remote_apply for logical replication?

2017-01-21 Thread Petr Jelinek

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


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] remote_apply for logical replication?

2017-01-20 Thread Thomas Munro
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?

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?

-- 
Thomas Munro
http://www.enterprisedb.com


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers