1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-01 01:04:50 +03:00

Improve documentation and comment for quorum-based sync replication.

Author: Masahiko Sawada, heavily modified by me
Discussion: http://postgr.es/m/CAHGQGwEKOw=SmPLxJzkBsH6wwDBgOnVz46QjHbtsiZ-d-2RGUg@mail.gmail.com
This commit is contained in:
Fujii Masao 2017-04-19 02:58:28 +09:00
parent e240a65c7d
commit a790ed9f69
2 changed files with 21 additions and 5 deletions

View File

@ -1084,8 +1084,8 @@ primary_slot_name = 'node_a_slot'
In the case that <varname>synchronous_commit</> is set to In the case that <varname>synchronous_commit</> is set to
<literal>remote_apply</>, the standby sends reply messages when the commit <literal>remote_apply</>, the standby sends reply messages when the commit
record is replayed, making the transaction visible. record is replayed, making the transaction visible.
If the standby is chosen as a synchronous standby, from a priority If the standby is chosen as a synchronous standby, according to the setting
list of <varname>synchronous_standby_names</> on the primary, the reply of <varname>synchronous_standby_names</> on the primary, the reply
messages from that standby will be considered along with those from other messages from that standby will be considered along with those from other
synchronous standbys to decide when to release transactions waiting for synchronous standbys to decide when to release transactions waiting for
confirmation that the commit record has been received. These parameters confirmation that the commit record has been received. These parameters
@ -1246,9 +1246,20 @@ synchronous_standby_names = 'FIRST 2 (s1, s2, s3)'
The best solution for high availability is to ensure you keep as many The best solution for high availability is to ensure you keep as many
synchronous standbys as requested. This can be achieved by naming multiple synchronous standbys as requested. This can be achieved by naming multiple
potential synchronous standbys using <varname>synchronous_standby_names</>. potential synchronous standbys using <varname>synchronous_standby_names</>.
The standbys whose names appear earlier in the list will be used as </para>
synchronous standbys. Standbys listed after these will take over
the role of synchronous standby if one of current ones should fail. <para>
In a priority-based synchronous replication, the standbys whose names
appear earlier in the list will be used as synchronous standbys.
Standbys listed after these will take over the role of synchronous standby
if one of current ones should fail.
</para>
<para>
In a quorum-based synchronous replication, all the standbys appearing
in the list will be used as candidates for synchronous standbys.
Even if one of them should fail, the other standbys will keep performing
the role of candidates of synchronous standby.
</para> </para>
<para> <para>

View File

@ -53,6 +53,10 @@
* in the list. All the standbys appearing in the list are considered as * in the list. All the standbys appearing in the list are considered as
* candidates for quorum synchronous standbys. * candidates for quorum synchronous standbys.
* *
* If neither FIRST nor ANY is specified, FIRST is used as the method.
* This is for backward compatibility with 9.6 or before where only a
* priority-based sync replication was supported.
*
* Before the standbys chosen from synchronous_standby_names can * Before the standbys chosen from synchronous_standby_names can
* become the synchronous standbys they must have caught up with * become the synchronous standbys they must have caught up with
* the primary; that may take some time. Once caught up, * the primary; that may take some time. Once caught up,
@ -629,6 +633,7 @@ SyncRepGetNthLatestSyncRecPtr(XLogRecPtr *writePtr, XLogRecPtr *flushPtr,
i++; i++;
} }
/* Sort each array in descending order */
qsort(write_array, len, sizeof(XLogRecPtr), cmp_lsn); qsort(write_array, len, sizeof(XLogRecPtr), cmp_lsn);
qsort(flush_array, len, sizeof(XLogRecPtr), cmp_lsn); qsort(flush_array, len, sizeof(XLogRecPtr), cmp_lsn);
qsort(apply_array, len, sizeof(XLogRecPtr), cmp_lsn); qsort(apply_array, len, sizeof(XLogRecPtr), cmp_lsn);