pgsql: Support multiple synchronous standby servers. - Mailing list pgsql-committers

From Fujii Masao
Subject pgsql: Support multiple synchronous standby servers.
Date
Msg-id E1aniiT-00083J-4W@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Support multiple synchronous standby servers.

Previously synchronous replication offered only the ability to confirm
that all changes made by a transaction had been transferred to at most
one synchronous standby server.

This commit extends synchronous replication so that it supports multiple
synchronous standby servers. It enables users to consider one or more
standby servers as synchronous, and increase the level of transaction
durability by ensuring that transaction commits wait for replies from
all of those synchronous standbys.

Multiple synchronous standby servers are configured in
synchronous_standby_names which is extended to support new syntax of
'num_sync ( standby_name [ , ... ] )', where num_sync specifies
the number of synchronous standbys that transaction commits need to
wait for replies from and standby_name is the name of a standby
server.

The syntax of 'standby_name [ , ... ]' which was used in 9.5 or before
is also still supported. It's the same as new syntax with num_sync=1.

This commit doesn't include "quorum commit" feature which was discussed
in pgsql-hackers. Synchronous standbys are chosen based on their priorities.
synchronous_standby_names determines the priority of each standby for
being chosen as a synchronous standby. The standbys whose names appear
earlier in the list are given higher priority and will be considered as
synchronous. Other standby servers appearing later in this list
represent potential synchronous standbys.

The regression test for multiple synchronous standbys is not included
in this commit. It should come later.

Authors: Sawada Masahiko, Beena Emerson, Michael Paquier, Fujii Masao
Reviewed-By: Kyotaro Horiguchi, Amit Kapila, Robert Haas, Simon Riggs,
Amit Langote, Thomas Munro, Sameer Thakur, Suraj Kharage, Abhijit Menon-Sen,
Rajeev Rastogi

Many thanks to the various individuals who were involved in
discussing and developing this feature.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/989be0810dffd08b54e1caecec0677608211c339

Modified Files
--------------
doc/src/sgml/config.sgml                      |  49 ++-
doc/src/sgml/high-availability.sgml           |  76 +++-
src/backend/Makefile                          |   4 +-
src/backend/replication/.gitignore            |   2 +
src/backend/replication/Makefile              |  11 +-
src/backend/replication/syncrep.c             | 549 ++++++++++++++++++++------
src/backend/replication/syncrep_gram.y        |  86 ++++
src/backend/replication/syncrep_scanner.l     | 144 +++++++
src/backend/replication/walsender.c           |  19 +-
src/backend/utils/misc/guc.c                  |   2 +-
src/backend/utils/misc/postgresql.conf.sample |   2 +-
src/include/replication/syncrep.h             |  31 +-
src/tools/msvc/Mkvcbuild.pm                   |   2 +-
13 files changed, 806 insertions(+), 171 deletions(-)


pgsql-committers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: pgsql: Avoid archiving XLOG_RUNNING_XACTS on idle server
Next
From: Andres Freund
Date:
Subject: Re: [HACKERS] pgsql: Avoid archiving XLOG_RUNNING_XACTS on idle server