pgsql: Support multiple synchronous standby servers.

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Support multiple synchronous standby servers.
Date: 2016-04-06 08:21:33
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: 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

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.



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/ | 2 +-
13 files changed, 806 insertions(+), 171 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2016-04-06 08:45:34 Re: [HACKERS] pgsql: Avoid archiving XLOG_RUNNING_XACTS on idle server
Previous Message Simon Riggs 2016-04-06 08:18:54 Re: pgsql: Avoid archiving XLOG_RUNNING_XACTS on idle server