multimaster.heartbeat_recv_timeout
Timeout, in milliseconds. If no heartbeat message is received from the node within this timeframe, the node is excluded from the cluster. Default: 2000 ms
multimaster.heartbeat_send_timeout
Time interval between heartbeat messages, in milliseconds. An arbiter process broadcasts heartbeat messages to all nodes to detect connection problems. Default: 200 ms
multimaster.max_workers
The maximum number of walreceiver workers per peer node. Default: 100
multimaster.monotonic_sequences
Defines the sequence generation mode for unique identifiers.
Default: false
multimaster.referee_connstring
Connection string to access the referee node. You must set this parameter on all cluster nodes if the referee is set up.
multimaster.remote_functions
Provides a comma-separated list of function names that should be executed remotely on all multimaster nodes instead of replicating the result of their work.
multimaster.trans_spill_threshold
The maximal size of transaction, in kB. When this threshold is reached, the transaction is written to the disk. Default: 100MB
multimaster.break_connection
Break connection with clients connected to the node if this node disconnects from the cluster. If this variable is set to false, the client stays connected to the node but receives an error that the node is disabled. Default: false
mtm.init_cluster(my_conninfo text, peers_conninfo text[])
Initializes cluster configuration on all nodes. It connects the current node to all nodes listed in peers_conninfo and creates the multimaster extension, replications slots, and replication origins on each node. Run this function once all the nodes are running and can accept connections.
Arguments:
my_conninfo
- connection string to the node on which you are running this function. Peer nodes use this string to connect back to this node.peers_conninfo
- an array of connection strings to all the other nodes to be added to the cluster.
mtm.add_node(connstr text)
Adds a new node to the cluster. This function should be called before loading data to this node using pg_basebackup. mtm.add_node creates the required replication slots for a new node, so you can add a node while the cluster is under load.
Arguments:
connstr
- connection string for the new node. For example, for the database mydb, user mtmuser, and the new node node4, the connection string is "dbname=mydb user=mtmuser host=node4".
mtm.join_node(node_id int, backup_end_lsn pg_lsn)
Completes the cluster setup after adding a new node. This function should be called after the added node has been started.
Arguments:
node_id
- ID of the node to add to the cluster. It corresponds to the value in the id column returned by mtm.nodes().backup_end_lsn
- the last LSN of the base backup copied to the new node. This LSN will be used as the starting point for data replication once the node joins the cluster.
mtm.drop_node(node_id integer)
Excludes a node from the cluster.
If you would like to continue using this node outside of the cluster in the standalone mode, you have to uninstall the multimaster extension from this node.
Arguments:
node_id
- ID of the node being dropped. It corresponds to the value in the id column returned by mtm.nodes().
mtm.alter_sequences()
Fixes unique identifiers on all cluster nodes. This may be required after restoring all nodes from a single base backup.
mtm.status()
Shows the status of the multimaster extension on the current node. Returns a tuple of the following values:
my_node_id, int
- ID of this nodestatus, text
- status of the node. Possible values are: online, recovery, catchup, disabled (need to recover, but not yet clear from whom), isolated (online in current generation, but some members are disconnected).connected, int[]
- array of peer IDs connected to this node.gen_num, int8
- current generation number.gen_members, int[]
- array of current generation members node IDs.gen_members_online, int[]
- array of current generation members node IDs which are online in it.gen_configured, int[]
- array of node IDs configured in current generation.
mtm.nodes()
Shows the information on all nodes in the cluster. Returns a tuple of the following values:
id, integer
- node ID.conninfo, text
- connection string to this node.is_self, boolean
- is it me?enabled, boolean
- is this node online in current generation?connected, boolean
- shows whether the node is connected to our node.sender_pid, integer
- WAL sender process ID.receiver_pid, integer
- WAL receiver process ID.n_workers, text
- number of started dynamic apply workers from this node.receiver_mode, text
- in which mode receiver from this node works. Possible values are: disabled, recovery, normal.
mtm.make_table_local(relation regclass)
Stops replication for the specified table.
Arguments:
relation
- the table you would like to exclude from the replication scheme.
mtm.check_query(query_text text)
Checks data consistency across cluster nodes. This function takes a snapshot of the current state of each node, runs the specified query against these snapshots, and compares the results. If the results are different between any two nodes, displays a warning with the first found issue and returns false. Otherwise, returns true.
Arguments:
query_text
- the query you would like to run on all nodes for data comparison. To avoid false-positive results, always use the ORDER BY clause in the test query.
mtm.get_snapshots()
Takes a snapshot of data on each cluster node and returns the snapshot ID. The snapshots remain available until the mtm.free_snapshots()
is called, or the current session is terminated. This function is used by the mtm.check_query(query_text)
, there is no need to call it manually.
mtm.free_snapshots()
Removes data snapshots taken by the mtm.get_snapshots()
function. This function is used by the mtm.check_query(query_text)
, there is no need to call it manually.