You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-3Lines changed: 28 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,11 +7,12 @@ See also [TypeScript API documentation](https://github.com/clickup/pg-microshard
7
7
The [pg-microsharding](https://www.npmjs.com/package/@clickup/pg-microsharding) CLI tool enables microshard schemas management across multiple PostgreSQL servers. You can do the following:
8
8
9
9
* Add and remove microshard schemas.
10
-
* Activate and deactivate schemas.
11
-
* Enumerate active microshard schemas.
12
-
* View the entire cluster layout: what microshard schemas are where, of what size, and how many reads/writes do the experience.
13
10
* Move a microshard from one PostgreSQL server to another with no downtime.
14
11
* Automatically rebalance microshards among multiple servers, so that each server will become of approximately the same size.
12
+
* Copy regular PostgreSQL schemas (unrelated to microshards) from one host to another without downtime (think of no-downtime dump-restore workflow).
13
+
* Activate and deactivate microshards.
14
+
* Enumerate active microshard schemas.
15
+
* View the entire cluster layout: what microshard schemas are where, of what size, and how many reads/writes do the experience.
15
16
* Weighted rebalancing: when one server looks overloaded, you can "dissolve out" some shards from it to other servers to achieve equal load.
16
17
17
18
Each microshard is a PostgreSQL schema with numeric suffix. Microshard schemas have the same set of tables with same names; it's up to the higher-level tools to keep the schemas of all those tables in sync (e.g. see [pg-mig](https://www.npmjs.com/package/@clickup/pg-mig) tool).
@@ -27,6 +28,7 @@ pg-microsharding list | ls
27
28
[--weight-sql='SELECT returning weight with optional unit']
28
29
[--verbose]
29
30
[--dsn=DSN | --dsns=DNS1,DSN2,...]
31
+
[--json]
30
32
31
33
pg-microsharding allocate
32
34
--shard=N | --shards=N-M
@@ -56,6 +58,14 @@ pg-microsharding rebalance
56
58
57
59
pg-microsharding cleanup
58
60
[--dsn=DSN | --dsns=DNS1,DSN2,...]
61
+
62
+
pg-microsharding copy
63
+
--schema=SCHEMA-NAME
64
+
--from=DSN-OR-DSN-PREFIX-OR
65
+
--to=DSN-OR-DSN-PREFIX
66
+
[--wait]
67
+
[--max-replication-lag-sec=N]
68
+
[--dsns=DNS1,DSN2,...]
59
69
```
60
70
61
71
## Environment Variables
@@ -136,6 +146,8 @@ pg-microsharding list
136
146
137
147
This action prints the list of all PostgreSQL islands (pointed by DNSn), microshards and some statistics.
138
148
149
+
If `--json` flag is passed, prints a JSON version of the output. Otherwise, prints a pseudo-graphic representation.
150
+
139
151
In `--verbose` mode, also prints detailed statistics about insert/update/delete, index scans and seqscans.
@@ -242,6 +254,19 @@ When you run `pg-microsharding factor --factor="*1.2"`, the tool artificially in
242
254
243
255
The "weight increase factor" is technically stored as a SQL comment on the microshard schema, and it travels along with the microshard when you move it.
244
256
257
+
### Dump-Restore a Schema with no Downtime: pg-microsharding copy
258
+
259
+
```bash
260
+
pg-microsharding copy \
261
+
--schema=my-schema --from=host1 --to=host2 \
262
+
--wait \
263
+
--max-replication-lag-sec=20
264
+
```
265
+
266
+
This action works very similarly to the move action, but it doesn't deactivate/activate microshards, so it may be used for other regular PostgreSQL schemas. Unlike when using regular `pg_dump` and restoring, you may continue sending writes to the source host, and the changes will eventually be replayed on the destination while the action is running.
267
+
268
+
It is very convenient to run this action with`--wait` flag:inthis case, it will ask for the user confirmation right before removing the logical subscription, so you'll have a chance to stop writes on the source host and quickly reroute the traffic to destination before finishing the action and removing the logical subscription.
269
+
245
270
### Replication Lag Prevention
246
271
247
272
The tool tries hard to not affect the replication lag of the destination nodes when moving or rebalancing microshards. It waits until the lag drops below `--max-replication-lag-sec` seconds before running heavy operations (or until the user presses Shift+S to force-continue).
Copy file name to clipboardExpand all lines: docs/README.md
+28-3Lines changed: 28 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,11 +11,12 @@ See also [TypeScript API documentation](https://github.com/clickup/pg-microshard
11
11
The [pg-microsharding](https://www.npmjs.com/package/@clickup/pg-microsharding) CLI tool enables microshard schemas management across multiple PostgreSQL servers. You can do the following:
12
12
13
13
* Add and remove microshard schemas.
14
-
* Activate and deactivate schemas.
15
-
* Enumerate active microshard schemas.
16
-
* View the entire cluster layout: what microshard schemas are where, of what size, and how many reads/writes do the experience.
17
14
* Move a microshard from one PostgreSQL server to another with no downtime.
18
15
* Automatically rebalance microshards among multiple servers, so that each server will become of approximately the same size.
16
+
* Copy regular PostgreSQL schemas (unrelated to microshards) from one host to another without downtime (think of no-downtime dump-restore workflow).
17
+
* Activate and deactivate microshards.
18
+
* Enumerate active microshard schemas.
19
+
* View the entire cluster layout: what microshard schemas are where, of what size, and how many reads/writes do the experience.
19
20
* Weighted rebalancing: when one server looks overloaded, you can "dissolve out" some shards from it to other servers to achieve equal load.
20
21
21
22
Each microshard is a PostgreSQL schema with numeric suffix. Microshard schemas have the same set of tables with same names; it's up to the higher-level tools to keep the schemas of all those tables in sync (e.g. see [pg-mig](https://www.npmjs.com/package/@clickup/pg-mig) tool).
@@ -31,6 +32,7 @@ pg-microsharding list | ls
31
32
[--weight-sql='SELECT returning weight with optional unit']
32
33
[--verbose]
33
34
[--dsn=DSN | --dsns=DNS1,DSN2,...]
35
+
[--json]
34
36
35
37
pg-microsharding allocate
36
38
--shard=N | --shards=N-M
@@ -60,6 +62,14 @@ pg-microsharding rebalance
60
62
61
63
pg-microsharding cleanup
62
64
[--dsn=DSN | --dsns=DNS1,DSN2,...]
65
+
66
+
pg-microsharding copy
67
+
--schema=SCHEMA-NAME
68
+
--from=DSN-OR-DSN-PREFIX-OR
69
+
--to=DSN-OR-DSN-PREFIX
70
+
[--wait]
71
+
[--max-replication-lag-sec=N]
72
+
[--dsns=DNS1,DSN2,...]
63
73
```
64
74
65
75
## Environment Variables
@@ -140,6 +150,8 @@ pg-microsharding list
140
150
141
151
This action prints the list of all PostgreSQL islands (pointed by DNSn), microshards and some statistics.
142
152
153
+
If `--json` flag is passed, prints a JSON version of the output. Otherwise, prints a pseudo-graphic representation.
154
+
143
155
In `--verbose` mode, also prints detailed statistics about insert/update/delete, index scans and seqscans.
@@ -246,6 +258,19 @@ When you run `pg-microsharding factor --factor="*1.2"`, the tool artificially in
246
258
247
259
The "weight increase factor" is technically stored as a SQL comment on the microshard schema, and it travels along with the microshard when you move it.
248
260
261
+
### Dump-Restore a Schema with no Downtime: pg-microsharding copy
262
+
263
+
```bash
264
+
pg-microsharding copy \
265
+
--schema=my-schema --from=host1 --to=host2 \
266
+
--wait \
267
+
--max-replication-lag-sec=20
268
+
```
269
+
270
+
This action works very similarly to the move action, but it doesn't deactivate/activate microshards, so it may be used for other regular PostgreSQL schemas. Unlike when using regular `pg_dump` and restoring, you may continue sending writes to the source host, and the changes will eventually be replayed on the destination while the action is running.
271
+
272
+
It is very convenient to run this action with`--wait` flag:inthis case, it will ask for the user confirmation right before removing the logical subscription, so you'll have a chance to stop writes on the source host and quickly reroute the traffic to destination before finishing the action and removing the logical subscription.
273
+
249
274
### Replication Lag Prevention
250
275
251
276
The tool tries hard to not affect the replication lag of the destination nodes when moving or rebalancing microshards. It waits until the lag drops below `--max-replication-lag-sec` seconds before running heavy operations (or until the user presses Shift+S to force-continue).
0 commit comments