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

Commit 5a531a1

Browse files
committed
Docs update
Introduction, short architecture, formulas for LR gucs.
1 parent 0032739 commit 5a531a1

File tree

3 files changed

+65
-12
lines changed

3 files changed

+65
-12
lines changed

postgresql.conf.common.template

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,34 @@ log_replication_commands = on
1212
# We use logical replication for sending metadata from shardlord to workers
1313
# and for data replication.
1414
wal_level = logical # necessary for logical replication
15-
# On shardlord, this must be at least max number of workers + some reserved for
16-
# initial tablesync. On workers, this must be at least max number of shards on
17-
# the node with 'prev' replica + max number of shards on the node
18-
# with 'next' replica (yes, with overlapping) + some reserved for initial
19-
# tablesync.
15+
16+
# On shardlord, this must be at least max number of worker nodes + some reserved
17+
# for initial tablesync.
18+
#
19+
# On worker node 'A', this must be at least 'mrs':
20+
# mrs = 1
21+
# for each sharded table t
22+
# for each primary shard of t lying on A
23+
# mrs += number of this shard replicas
24+
# for each replica shard of t lying on A
25+
# mrs++
26+
#
27+
# For example, imagine we have one sharded table with 10 partitions, replication
28+
# factor 3 (1 primary and 2 replicas for each shard), 5 nodes and distribute
29+
# data evenly so that each node has 6 shards. In the almost worst case, if node
30+
# A keeps 5 primaries and 1 replica, this node needs 1 + 5*2 + 1 = 12 repslots.
2031
max_replication_slots = 100
21-
# Similar is true for max_wal_senders: shardlord this should have this equal to
22-
# max_replication_slots. On workers, this must be at least max number of shards
23-
# on the table which have 'next' replica.
32+
33+
# Similar is true for max_wal_senders. Shardlord should have this at equal
34+
# max_replication_slots.
35+
36+
# On worker node 'A', this must be at least 'mws':
37+
# mws = 0
38+
# for each sharded table t
39+
# for each primary shard of t lying on A
40+
# mrs += number of this shard replicas
41+
#
42+
# So it is 5*2 = 10 walsenders in previous example.
2443
max_wal_senders = 50
2544

2645
# never set this to 'off' globally while using pg_shardman if you want

postgresql.conf.worker.template

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# At least number of shards with 'prev' replica + reserve for initial tablesync.
1+
# On worker node 'A', this must be at least 'mrs':
2+
# mrs = 1
3+
# for each sharded table t
4+
# for each replica shard of t lying on A
5+
# mrs++
6+
#
7+
# So it is 1 + 1 = 2 for node A from example in postgresql.conf.common.template
28
max_logical_replication_workers = 50
39
# At least max_logical_replication_workers + 1
410
max_worker_processes = 60

readme.txt

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,32 @@
11
pg_shardman: PostgreSQL sharding built on pg_pathman, postgres_fdw and logical
22
replication.
33

4-
First, some terminology:
4+
pg_shardman aims for write scalability and high availability. It allows to
5+
partition tables using pg_pathman and move them across nodes, balancing write
6+
load. You can issue queries to any node, postgres_fdw is responsible for
7+
redirecting them to proper node. To avoid data loss, we support replication of
8+
partitions via synchronous logical replication (LR), each partition can have as
9+
many replicas on other nodes as you like.
10+
11+
To manage this zoo, we need one designated node which we call 'shardlord'. This
12+
node accepts sharding commands from the user and makes sure the whole cluster
13+
changes its state as desired. Shardlord rules other nodes in two ways, depending
14+
on what needs to be done. The first is quite straightforward, it is used for
15+
targeted changes on several nodes, e.g. configure LR channel between nodes --
16+
shardlord just connects via libpq to the nodes as a normal PostgreSQL client.
17+
The second is a bit more perverted, it is used for bulk update of something,
18+
e.g. update fdw servers after partition move. Shardlord keeps several tables
19+
(see below) forming cluster metadata -- which nodes are in cluster and which
20+
partitions they keep. It creates one async LR channel to each other node,
21+
replicating these tables. Nodes have triggers firing when something in these
22+
tables changes, and update their state accordingly.
23+
24+
During normal operation you shoudn't care much about how shardlord
25+
works. However, it is useful to understand that when something goes wrong.
26+
27+
So, some terminology:
28+
'commands' is what constitutes shardman interface: functions for sharding
29+
management.
530
'shardlord' or 'lord' is postgres instance and background process (bgw) spinning
631
on it which manages sharding.
732
'worker nodes' or 'workers' are other nodes with data.
@@ -23,8 +48,9 @@ Both shardlord and workers require extension built and installed. We depend
2348
on pg_pathman extension so it must be installed too.
2449
PostgreSQL location for building is derived from pg_config, you can also specify
2550
path to it in PG_CONFIG var. PostgreSQL 10 (REL_10_STABLE branch as of writing
26-
this) is required. Extension links with libpq, so if you The whole process of
27-
building and copying files to PG server is just:
51+
this) is required. Extension links with libpq, so if you install PG from
52+
packages, you should install libpq-dev package. The whole process of building
53+
and copying files to PG server is just:
2854

2955
git clone
3056
cd pg_shardman
@@ -185,3 +211,5 @@ Limitations:
185211
* We can't switch shardlord for now.
186212
* The shardlord itself can't be worker node for now.
187213
* ALTER TABLE for sharded tables is not supported.
214+
* Cmd redirection is not yet implemented, sharding cmds must be issued to
215+
shardlord directly.

0 commit comments

Comments
 (0)