pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Jesper Pedersen <jesper.pedersen@redhat.com>
Cc: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: pg_receivewal documentation
Date: Fri, 19 Jul 2019 10:09:03 +0900
Message-ID: <20190719010903.GC1859@paquier.xyz> (raw)
In-Reply-To: <e62fcdf7-556c-d4e1-73cd-fc325f89374d@redhat.com>
References: <54779de5-f922-c0cf-629d-b582eded7265@redhat.com>
	<20190716050555.GA1439@paquier.xyz>
	<ebed4b9043b222d486ea3f0e44e7dcd242a80781.camel@cybertec.at>
	<65c3ecdf-8995-34cb-83c4-50068877e632@redhat.com>
	<20190717013835.GA2130@paquier.xyz>
	<44e51f9f60abb872854879c91da0ed3b67a6ba95.camel@cybertec.at>
	<20190717080424.GB20614@paquier.xyz>
	<7eaf748c-3f40-c994-0eb3-7d87709588d0@redhat.com>
	<184780f1f90a31c4c8b53f0e6328bf5aaae4f786.camel@cybertec.at>
	<e62fcdf7-556c-d4e1-73cd-fc325f89374d@redhat.com>

On Thu, Jul 18, 2019 at 08:39:48AM -0400, Jesper Pedersen wrote:
> mkdir /tmp/wal
> initdb /tmp/pgsql
> pg_ctl -D /tmp/pgsql -l /tmp/logfile start
> psql postgres
> SELECT pg_create_physical_replication_slot('replica1');
> CREATE ROLE repluser WITH LOGIN REPLICATION PASSWORD 'replpass';
> \q
> 
> synchronous_commit = on
> synchronous_standby_names = 'replica1'
> 
> pg_ctl -D /tmp/pgsql -l /tmp/logfile restart
> pg_receivewal -D /tmp/wal -S replica1 --synchronous -h localhost -p 5432 -U
> repluser -W
> psql -c 'SELECT * FROM pg_stat_replication;' postgres
> psql -c 'SELECT * FROM pg_replication_slots;' postgres
> psql -c 'CREATE DATABASE test' postgres
> 
> In what scenarios do you see 'on' working ?

Because the code says so, "on" is an alias for "remote_flush" (which
is not user-visible by the way):
src/include/access/xact.h:#define SYNCHRONOUS_COMMIT_ON
SYNCHRONOUS_COMMIT_REMOTE_FLUSH

And if you do that it works fine (pg_receivewal --synchronous runs in
the background and I created a dummy table):
=# SELECT application_name, sync_state, flush_lsn, replay_lsn FROM
pg_stat_replication;
 application_name | sync_state | flush_lsn | replay_lsn
------------------+------------+-----------+------------
 pg_receivewal    | sync       | 0/15E1F88 | null
(1 row)
=# set synchronous_commit to on ;
SET
=# insert into aa values (2);
INSERT 0 1

This part however is as expected, just blocking:
=# set synchronous_commit to remote_apply ;
SET
=# insert into aa values (3);
^CCancel request sent
WARNING:  01000: canceling wait for synchronous replication due to
user request
DETAIL:  The transaction has already committed locally, but might not
have been replicated to the standby.
LOCATION:  SyncRepWaitForLSN, syncrep.c:266
INSERT 0 1
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (37+ messages)  latest in thread

Message-ID: <20190719010903.GC1859@paquier.xyz>
Permalink:  ../20190719010903.GC1859@paquier.xyz/
Also on:    postgresql.org/message-id/20190719010903.GC1859@paquier.xyz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: michael@paquier.xyz, jesper.pedersen@redhat.com, laurenz.albe@cybertec.at, alvherre@2ndquadrant.com
  Subject: Re: pg_receivewal documentation
  In-Reply-To: <20190719010903.GC1859@paquier.xyz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox