1
1
pg_shardman: PostgreSQL sharding built on pg_pathman, postgres_fdw and logical
2
2
replication.
3
3
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.
5
30
'shardlord' or 'lord' is postgres instance and background process (bgw) spinning
6
31
on it which manages sharding.
7
32
'worker nodes' or 'workers' are other nodes with data.
@@ -23,8 +48,9 @@ Both shardlord and workers require extension built and installed. We depend
23
48
on pg_pathman extension so it must be installed too.
24
49
PostgreSQL location for building is derived from pg_config, you can also specify
25
50
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:
28
54
29
55
git clone
30
56
cd pg_shardman
@@ -185,3 +211,5 @@ Limitations:
185
211
* We can't switch shardlord for now.
186
212
* The shardlord itself can't be worker node for now.
187
213
* 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