Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1674ae7

Browse files
author
Liudmila Mantrova
committed
Bug fixes for multimaster docs
1 parent 8e5c8e9 commit 1674ae7

File tree

1 file changed

+110
-31
lines changed

1 file changed

+110
-31
lines changed

doc/src/sgml/multimaster.sgml

Lines changed: 110 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,10 @@ where <replaceable>datadir</> is the directory containing the database cluster.
360360
<programlisting>
361361
shared_preload_libraries = 'multimaster'
362362
</programlisting>
363+
<tip>
364+
<para>If the <varname>shared_preload_libaries</varname> variable is already defined in <filename>postgresql.auto.conf</filename>, you will need to modify its value using the <literal>ALTER SYSTEM</literal> command. For details, see <xref linkend="config-setting-configuration-file">.
365+
</para>
366+
</tip>
363367
</listitem>
364368
<listitem><para>Specify the transaction isolation level for your cluster. <filename>multimaster</filename> currently supports <link linkend="xact-read-committed">read committed</link> and <link linkend="xact-repeatable-read">repeatable read</link> isolation levels.
365369
<programlisting>
@@ -426,15 +430,19 @@ multimaster.conn_strings = 'dbname=mydb user=myuser host=node1, dbname=mydb user
426430
# of connection strings
427431
# to neighbor nodes
428432
</programlisting>
429-
<para>The <literal>max_nodes</literal> variable defines the cluster size. In most cases, three cluster nodes are enough to ensure high availability. Since the data on all cluster nodes is the same, you do not typically need more than five cluster nodes.</para>
433+
<para>The <literal>multimaster.max_nodes</literal> variable defines the maximum cluster size. If you plan to add new nodes to your cluster, the <literal>multimaster.max_nodes</literal> value should exceed the initial number of nodes. In this case, you can add new nodes without restarting <productname>&productname;</productname>.
434+
</para>
435+
<para>In most cases, three cluster nodes are enough to ensure high availability. Since the data on all cluster nodes is the same, you do not typically need more than five cluster nodes.
436+
</para>
437+
<para>If you would like to change the default connection settings for a cluster node, you can add other <link linkend="libpq-paramkeywords"> connection parameters</link> to the corresponding connection string in the <varname>multimaster.conn_strings</varname> variable. Additionally, you can specify the <literal>arbiter_process</literal> parameter to change the port used by the arbiter process to connect to the nodes. For details, see <xref linkend="multimaster-conn-strings"> and <xref linkend="multimaster-arbiter-port">.</para>
430438
<important><para>The
431-
<literal>node_id</literal> variable takes natural
439+
<literal>multimaster.node_id</literal> variable takes natural
432440
numbers starting from 1, without any gaps in numbering.
433441
For example, for a cluster of five nodes, set node IDs
434442
to 1, 2, 3, 4, and 5. In the
435-
<literal>conn_strings</literal> variable, make sure to
443+
<literal>multimaster.conn_strings</literal> variable, make sure to
436444
list the nodes in the order of their IDs. The
437-
<literal>conn_strings</literal> variable must be the
445+
<literal>multimaster.conn_strings</literal> variable must be the
438446
same on all nodes.</para></important>
439447

440448
</listitem>
@@ -533,20 +541,12 @@ SELECT * FROM mtm.get_cluster_state();
533541
following variables:
534542
</para>
535543
<itemizedlist>
536-
<listitem>
537-
<para>
538-
<varname>multimaster.max_recovery_lag</varname> &mdash; sets the
539-
maximum size of WAL. Upon reaching the
540-
<varname>multimaster.max_recovery_lag</varname> threshold,
541-
WAL for the disconnected node is overwritten. At this
542-
point, automatic recovery is no longer possible. In this case, you can <link linkend="multimaster-restoring-a-node-manually">restore the node manually</link> by cloning the data from one of the alive nodes using <application>pg_basebackup</application>.
543-
</para>
544-
</listitem>
545544
<listitem>
546545
<para>
547546
<varname>multimaster.min_recovery_lag</varname> &mdash; sets the
548-
minimal WAL lag between the node to be restored and the current cluster state. When the
549-
disconnected node is fast-forwarded up to the
547+
minimal WAL lag between the node to be restored and the current cluster state.
548+
By default, <varname>multimaster.min_recovery_lag</varname> is set to 100KB.
549+
When the disconnected node is fast-forwarded up to the
550550
<varname>multimaster.min_recovery_lag</varname> threshold,
551551
<filename>multimaster</filename> stops all new commits to the
552552
alive nodes until the node fully catches up with the
@@ -555,10 +555,19 @@ SELECT * FROM mtm.get_cluster_state();
555555
the cluster resumes its work.
556556
</para>
557557
</listitem>
558+
<listitem>
559+
<para>
560+
<varname>multimaster.max_recovery_lag</varname> &mdash; sets the
561+
maximum size of WAL. Upon reaching the
562+
<varname>multimaster.max_recovery_lag</varname> threshold,
563+
WAL for the disconnected node is overwritten. At this
564+
point, automatic recovery is no longer possible. In this case, you can <link linkend="multimaster-restoring-a-node-manually">restore the node manually</link> by cloning the data from one of the alive nodes using <application>pg_basebackup</application>.
565+
</para>
566+
</listitem>
558567
</itemizedlist>
559568
<para>
560569
By default, <varname>multimaster.max_recovery_lag</varname> is
561-
set to 1GB. Setting
570+
set to 100MB. Setting
562571
<varname>multimaster.max_recovery_lag</varname> to a larger
563572
value increases the timeframe for automatic recovery, but
564573
requires more disk space for WAL collection.
@@ -670,7 +679,8 @@ pg_basebackup -D <replaceable>datadir</replaceable> -h node1 -x
670679
<programlisting>
671680
multimaster.max_nodes = 4
672681
multimaster.node_id = 4
673-
multimaster.conn_strings = 'dbname=mydb user=myuser host=node1, dbname=mydb user=myuser host=node2, dbname=mydb user=myuser host=node3, dbname=mydb user=myuser host=node4'
682+
multimaster.conn_strings = 'dbname=mydb user=myuser host=node1, dbname=mydb user=myuser host=node2,
683+
dbname=mydb user=myuser host=node3, dbname=mydb user=myuser host=node4'
674684
</programlisting>
675685
</listitem>
676686
<listitem>
@@ -690,8 +700,7 @@ pg_ctl -D <replaceable>datadir</replaceable> -l <replaceable>pg.log</replaceable
690700
<orderedlist>
691701
<listitem>
692702
<para>
693-
Change <literal>multimaster.conn_strings</literal> and
694-
<literal>multimaster.max_nodes</literal> to include the new node.
703+
Change <literal>multimaster.conn_strings</literal> and <literal>multimaster.max_nodes</literal> to include the new node.
695704
</para>
696705
</listitem>
697706
<listitem>
@@ -700,6 +709,11 @@ pg_ctl -D <replaceable>datadir</replaceable> -l <replaceable>pg.log</replaceable
700709
replication to the new node.
701710
</para>
702711
</listitem>
712+
<listitem>
713+
<para>
714+
Restart all cluster nodes.
715+
</para>
716+
</listitem>
703717
</orderedlist>
704718
<para>
705719
<emphasis role="strong">See Also</emphasis></para>
@@ -790,25 +804,30 @@ pg_ctl -D <replaceable>datadir</replaceable> -l <replaceable>pg.log</replaceable
790804
For example, for a cluster of five nodes, set node IDs to 1, 2, 3,
791805
4, and 5.
792806
</para></listitem></varlistentry>
793-
<varlistentry><term><varname>multimaster.conn_strings</varname><indexterm><primary><varname>multimaster.conn_strings</varname></primary></indexterm></term><listitem><para>
794-
Connection strings for
795-
each node of a multi-master cluster, separated by commas. Each
796-
connection string must include the name of the database to replicate
807+
<varlistentry id="multimaster-conn-strings"><term><varname>multimaster.conn_strings</varname><indexterm><primary><varname>multimaster.conn_strings</varname></primary></indexterm></term><listitem><para>
808+
Connection strings for each node of a multi-master cluster, separated by commas.
809+
The <varname>multimaster.conn_strings</varname> parameter must be identical on all nodes.
810+
Each connection string must include the name of the database to replicate
797811
and the cluster node domain name. For example, 'dbname=mydb
798812
host=node1, dbname=mydb host=node2, dbname=mydb host=node3'.
813+
Optionally, you can add other <link linkend="libpq-paramkeywords">connection parameters</link> to change the default connection settings.
799814
Connection strings must appear in the order of the node IDs
800815
specified in the <varname>multimaster.node_id</varname> variable.
801816
Connection string for the i-th node must be on the i-th position.
802-
This parameter must be identical on all nodes. You can also specify a
803-
custom port for all connection strings using the
804-
<varname>multimaster.arbiter_port</varname> variable.
817+
You can also specify a
818+
custom port for the arbiter to listen on using the <literal>arbiter_port</literal>
819+
parameter. The provided value must be the same as the <varname>multimaster.arbiter_port</varname>
820+
value specified for this node.
805821
</para></listitem></varlistentry>
806822
<varlistentry><term><varname>multimaster.max_nodes</varname><indexterm><primary><varname>multimaster.max_nodes</varname></primary></indexterm></term><listitem><para>
807-
The maximum number of nodes allowed in the cluster. In most cases, three cluster nodes are enough to ensure high availability. Since the data on all cluster nodes is the same, you do not typically need more than five cluster nodes. The maximum possible number of nodes is limited to 64.</para><para>Default: the number of nodes specified in the <varname>multimaster.conn_strings</varname> variable
823+
The maximum number of nodes allowed in the cluster. If you plan to add new nodes to your cluster, the <literal>multimaster.max_nodes</literal> value should exceed the initial number of nodes. In this case, you can add new nodes without restarting <productname>&productname;</productname>. In most cases, three cluster nodes are enough to ensure high availability. Since the data on all cluster nodes is the same, you do not typically need more than five cluster nodes. The maximum possible number of nodes is limited to 64.</para>
824+
<para>Default: the number of nodes specified in the <varname>multimaster.conn_strings</varname> variable
808825
</para></listitem></varlistentry>
809-
<varlistentry><term><varname>multimaster.arbiter_port</varname><indexterm><primary><varname>multimaster.arbiter_port</varname></primary></indexterm></term><listitem><para>
810-
Port for the arbiter
811-
process to listen on. </para><para>Default: 5433
826+
<varlistentry id="multimaster-arbiter-port">
827+
<term><varname>multimaster.arbiter_port</varname><indexterm><primary><varname>multimaster.arbiter_port</varname></primary></indexterm></term><listitem><para>
828+
Port for the arbiter process to listen on. If you change the default value, you must specify this value in the <literal>arbiter_port</literal>
829+
parameter in the connection string of the corresponding node.</para>
830+
<para>Default: 5433
812831
</para></listitem></varlistentry>
813832
<varlistentry><term><varname>multimaster.heartbeat_send_timeout</varname><indexterm><primary><varname>multimaster.heartbeat_send_timeout</varname></primary></indexterm></term><listitem><para>
814833
Time interval
@@ -841,7 +860,7 @@ pg_ctl -D <replaceable>datadir</replaceable> -l <replaceable>pg.log</replaceable
841860
the data from one of the alive nodes using
842861
<application>pg_basebackup</application> or a similar tool. If you set this
843862
variable to zero, replication slot will not be dropped. </para><para>Default:
844-
10000000
863+
100000000
845864
</para></listitem></varlistentry>
846865
<varlistentry><term><varname>multimaster.ignore_tables_without_pk</varname><indexterm><primary><varname>multimaster.ignore_tables_without_pk</varname></primary></indexterm></term><listitem><para>
847866
Boolean.
@@ -857,6 +876,66 @@ pg_ctl -D <replaceable>datadir</replaceable> -l <replaceable>pg.log</replaceable
857876
you set this variable, <filename>multimaster</filename> checks that
858877
the cluster name is the same for all the cluster nodes.
859878
</para></listitem></varlistentry>
879+
<varlistentry>
880+
<term><varname>multimaster.break_connection</varname>
881+
<indexterm><primary><varname>multimaster.break_connection</varname></primary>
882+
</indexterm>
883+
</term>
884+
<listitem>
885+
<para>Break connection with clients connected to the node if this node disconnects
886+
from the cluster. If this variable is set to <literal>false</literal>, the client stays
887+
connected to the node but receives an error that the node is in minority.
888+
</para>
889+
<para>Default: <literal>false</literal>
890+
</para>
891+
</listitem>
892+
</varlistentry>
893+
<varlistentry>
894+
<term><varname>multimaster.major_node</varname>
895+
<indexterm><primary><varname>multimaster.major_node</varname></primary>
896+
</indexterm>
897+
</term>
898+
<listitem>
899+
<para>Node with this flag continues working even if it cannot access the majority of other nodes.
900+
This is needed to break the symmetry if there is an even number of alive nodes in the cluster.
901+
For example, a cluster with three nodes continues working if one of the nodes has crashed.
902+
If connection between the remaining nodes is lost, the node with <varname>multimaster.major_node</varname> = <literal>true</literal> will continue working.
903+
</para>
904+
<important>
905+
<para>This parameter should be used with caution. Only one node in the cluster
906+
can have this parameter set to true. When set to <literal>true</literal> on several
907+
nodes, this parameter can cause the split-brain problem.
908+
</para>
909+
</important>
910+
</listitem>
911+
</varlistentry>
912+
<varlistentry>
913+
<term><varname>multimaster.max_workers</varname>
914+
<indexterm><primary><varname>multimaster.max_workers</varname></primary>
915+
</indexterm>
916+
</term>
917+
<listitem>
918+
<para>The maximum number of <literal>walreceiver</literal> workers on this server.
919+
</para>
920+
<important>
921+
<para>This parameter should be used with caution. If the number of simultaneous transactions
922+
in the whole cluster is bigger than the provided value, it can lead to undetected deadlocks.
923+
</para>
924+
</important>
925+
</listitem>
926+
</varlistentry>
927+
<varlistentry>
928+
<term><varname>multimaster.trans_spill_threshold</varname>
929+
<indexterm><primary><varname>multimaster.trans_spill_threshold</varname></primary>
930+
</indexterm>
931+
</term>
932+
<listitem>
933+
<para>The maximal size of transaction, in MB. When this threshold is reached, the transaction is written to the disk.
934+
</para>
935+
<para>Default: 100
936+
</para>
937+
</listitem>
938+
</varlistentry>
860939
</variablelist>
861940
</sect3>
862941
<sect3 id="multimaster-functions"><title>Functions</title>

0 commit comments

Comments
 (0)