Skip to content

Commit 6ca55e7

Browse files
committed
Merge branch 'PGPROEE9_6_MULTIMASTER' of https://gitlab.postgrespro.ru/pgpro-dev/postgrespro into PGPROEE9_6_MULTIMASTER
2 parents 936711f + c2d9a9c commit 6ca55e7

File tree

3 files changed

+47
-22
lines changed

3 files changed

+47
-22
lines changed

contrib/mmts/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ Cluster consisting of N nodes can continue to work while majority of initial nod
2222
## Documentation
2323

2424
1. [Administration](doc/administration.md)
25-
1. [Installation](doc/administration.md)
26-
1. [Setting up empty cluster](doc/administration.md)
27-
1. [Setting up cluster from pre-existing database](doc/administration.md)
28-
1. [Tuning configuration params](doc/administration.md)
29-
1. [Monitoring](doc/administration.md)
30-
1. [Adding nodes to cluster](doc/administration.md)
31-
1. [Excluding nodes from cluster](doc/administration.md)
25+
1. [Installation](doc/administration.md#installation)
26+
1. [Setting up empty cluster](doc/administration.md#setting-up-empty-cluster)
27+
1. [Setting up cluster from pre-existing database](doc/administration.md#setting-up-cluster-from-pre-existing-database)
28+
1. [Tuning configuration params](doc/administration.md#tuning-configuration-params)
29+
1. [Monitoring](doc/administration.md#monitoring)
30+
1. [Adding nodes to cluster](doc/administration.md#adding-nodes-to-cluster)
31+
1. [Excluding nodes from cluster](doc/administration.md#excluding-nodes-from-cluster)
3232
1. [Architecture and internals](doc/architecture.md)
3333
1. [List of configuration variables](doc/configuration.md)
3434
1. [Built-in functions and views](doc/configuration.md)

contrib/mmts/doc/administration.md

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# `Administration`
22

3-
1. [Installation](doc/administration.md)
4-
1. [Setting up empty cluster](doc/administration.md)
5-
1. [Setting up cluster from pre-existing database](doc/administration.md)
6-
1. [Tuning configuration params](doc/administration.md)
7-
1. [Monitoring](doc/administration.md)
8-
1. [Adding nodes to cluster](doc/administration.md)
9-
1. [Excluding nodes from cluster](doc/administration.md)
3+
1. [Installation](#installation)
4+
1. [Setting up empty cluster](#setting-up-empty-cluster)
5+
1. [Setting up cluster from pre-existing database](#setting-up-cluster-from-pre-existing-database)
6+
1. [Tuning configuration params](#tuning-configuration-params)
7+
1. [Monitoring](#monitoring)
8+
1. [Adding nodes to cluster](#adding-nodes-to-cluster)
9+
1. [Excluding nodes from cluster](#excluding-nodes-from-cluster)
1010

1111

1212

@@ -52,8 +52,14 @@ cd contrib/mmts && make install
5252

5353
### Docker
5454

55-
Directory contrib/mmts also includes docker-compose.yml that is capable of building multi-master and starting 3 node cluster listening on port 15432, 15433 and 15434.
55+
Directory contrib/mmts also includes docker-compose.yml that is capable of building multi-master and starting 3 node cluster.
5656

57+
First of all we need to build PGPro EE docker image (We will remove this step when we'll merge _MULTIMASTER branch and start building packages). In the repo root run:
58+
```
59+
docker build -t pgproent
60+
```
61+
62+
Then following command will start cluster of 3 docker nodes listening on port 15432, 15433 and 15434 (edit docker-compose.yml to change start params):
5763
```
5864
cd contrib/mmts
5965
docker-compose up
@@ -65,7 +71,7 @@ When things go more stable we will release prebuilt packages for major platforms
6571

6672

6773

68-
## Configuration
74+
## Setting up empty cluster
6975

7076
After installing software on all cluster nodes we can configure our cluster. Here we describe how to set up multimaster consisting of 3 nodes with empty database. Suppose our nodes accesible via domain names ```node1```, ```node2``` and ```node3```. Perform following steps on each node (sequentially or in parallel – doesn't matter):
7177

@@ -149,13 +155,32 @@ After installing software on all cluster nodes we can configure our cluster. Her
149155
150156
151157
## Setting up cluster from pre-existing database
158+
159+
In case of preexisting database setup would be slightly different. Suppose we have running database on server ```node1``` and wan't to turn it to a multimaster by adding two new nodes ```node2``` and ```node3```. Instead of initializing new directory and creating database and user through a temporary launch, one need to initialize new node through pg_basebackup from working node.
160+
161+
1. On each new node run:
162+
163+
```
164+
pg_basebackup -D ./datadir -h node1 mydb
165+
```
166+
167+
After that configure and atart multimaster from step 3 of previous section. See deteailed description of pg_basebackup options in the official [documentation](https://www.postgresql.org/docs/9.6/static/app-pgbasebackup.html).
168+
169+
152170
## Tuning configuration params
171+
172+
While multimaster is usable with default configuration optins several params may require tuning.
173+
174+
* Hearbeat timeouts — multimaster periodically send heartbeat packets to check availability of neighbour nodes. ```multimaster.heartbeat_send_timeout``` defines amount of time between sending heartbeats, while ```multimaster.heartbeat_recv_timeout``` sets amount of time following which node assumed to be disconnected if no hearbeats were received during this time. It's good idea to set ```multimaster.heartbeat_send_timeout``` based on typical ping latencies between you nodes. Small recv/senv ratio decraeases time of failure detection, but increases probability of false positive failure detection, so tupical packet loss ratio between nodes should be taken into account.
175+
176+
* Min/max recovery lag — when node is disconnected from the cluster other nodes will keep to collect WAL logs for disconnected node until size of WAL log will grow to ```multimaster.max_recovery_lag```. Upon reaching this threshold WAL logs for disconnected node will be deleted, automatic recovery will be no longer possible and disconnected node should be cloned manually from one of alive node by ```pg_basebackup```. Increasing ```multimaster.max_recovery_lag``` increases amount of time while automatic recovery is possible, but also increasing maximum disk usage during WAL collection. On the other hand ```multimaster.min_recovery_lag``` sets difference between acceptor and donor nodes before switching ordanary recovery to exclusive mode, when commits on donor node are stopped. This step is necessary to ensure that no new commits will happend during node promotion from recovery state to online state and nodes will be at sync after that.
177+
178+
153179
## Monitoring
154180
155181
* `mtm.get_nodes_state()` -- show status of nodes on cluster
156182
* `mtm.get_cluster_state()` -- show whole cluster status
157183
* `mtm.get_cluster_info()` -- print some debug info
158-
* `mtm.make_table_local(relation regclass)` -- stop replication for a given table
159184
160185
Read description of all management functions at [functions](doc/functions.md)
161186

src/backend/libpq/auth-scram.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -969,25 +969,25 @@ generate_nonce(char *result, int len)
969969
/* Use the salt generated for SASL authentication */
970970
memset(result, 0, len);
971971
if (MyProcPort == NULL) {
972-
int count;
972+
int count = 0;
973973
/* compute the salt to use for computing responses */
974974
while (count < sizeof(MyProcPort->SASLSalt) && count < len)
975975
{
976-
char byte;
976+
char byte;
977977
if (!pg_strong_random(&byte, 1))
978978
{
979979
elog(ERROR, "Could not generate random salt");
980-
}
980+
}
981981
/*
982982
* Only ASCII printable characters, except commas are accepted in
983983
* the nonce.
984984
*/
985985
if (byte < '!' || byte > '~' || byte == ',')
986986
continue;
987-
987+
988988
result[count++] = byte;
989989
}
990-
} else {
990+
} else {
991991
memcpy(result, MyProcPort->SASLSalt, Min(sizeof(MyProcPort->SASLSalt), len));
992992
}
993993
}

0 commit comments

Comments
 (0)