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

Commit 20fa71b

Browse files
committed
Minor doc fixes, pt_cleanup().
1 parent ff423db commit 20fa71b

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

readme.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ on shardlord with usual `CREATE TABLE` DDL and execute
172172
`shardman.create_hash_partitions` function, for example
173173

174174
```plpgsql
175-
CRATE TABLE horns (id int, branchness int);
175+
CRATE TABLE horns (id int primary key, branchness int);
176176
select create_hash_partitions('horns', 'id', 30, redundancy = 1)
177177
```
178178

@@ -181,7 +181,7 @@ On successfull execution, table `horns` will be hash-sharded into 30 partitions
181181
replica will be spawn and added to logical replication channel between nodes
182182
holding primary and replica.
183183

184-
After table was sharded, each `pg_shardman` node can execute any DML statement
184+
After table was sharded, each `pg_shardman` worker node can execute any DML statement
185185
involving it. You are free to issue queries involving data from more than one
186186
shard, remote or local. It works using standard Postgres inheritance mechanism:
187187
all partitions are derived from parent table. If a partition is located at some
@@ -194,6 +194,9 @@ on all nodes in parallel: foreign data wrappers do not support parallel scan
194194
because of using cursors. Execution of OLAP queries at `pg_shardman` might not
195195
be that efficient. `pg_shardman` is oriented mainly on OLTP workload.
196196

197+
Shardlord doesn't hold any data and can't read it, this node is used only for
198+
managing the cluster.
199+
197200
Presently internal Postgres function is used for hashing; there is no easy way
198201
for client app to determine the node for particular record to perform local
199202
reads/writes.
@@ -249,6 +252,10 @@ We don't track replication mode for each table separately, and changing
249252
`shardman.sync_replication` GUC during cluster operation might lead to a mess.
250253
It is better to set it permanently for now.
251254

255+
`pg_shardman` currently doesn't bothers itself with configuring replication
256+
identities. It is strongly recommended to use primary key as sharding key to
257+
avoid problems with `UPDATE` and `DELETE` operations.
258+
252259
### Balancing the load
253260

254261
Newly added nodes are initially empty. To bring some sense into their existence,
@@ -388,8 +395,11 @@ also create new indices. It must be done per each partition separately,
388395
see
389396
[pathman docs](https://github.com/postgrespro/pg_pathman/wiki/How-do-I-create-indexes)
390397

398+
`monitor` function on shardlord can continiously track failed nodes and resolve
399+
distributed deadlocks, see the reference.
400+
391401
If shardlord has failed during command execution or you just feel that something
392-
goes wrong, run `shadman.recover()` function. It will verify nodes state
402+
goes wrong, run `shardman.recover()` function. It will verify nodes state
393403
against current shardlord's metadata and try to fix up things, i.e. reconfigure
394404
LR channels, repair FDW, etc.
395405

@@ -505,6 +515,9 @@ more than one copy of the partition per node. Distributed table is always
505515
created empty, it doesn't matter had the original table on shardlord had any
506516
data or not.
507517

518+
Column(s) participating in `expr` must be marked `NOT NULL`, as in
519+
`pg_pathman`. Generally we strongly recommend to use primary key there.
520+
508521
```plpgsql
509522
rm_table(rel_name name)
510523
```
@@ -640,7 +653,7 @@ Data is not touched by this command.
640653
## Some limitations:
641654
* You should not touch `synchronous_standby_names` manually while using pg_shardman.
642655
* The shardlord itself can't be worker node for now.
643-
* All [limitations of `pg_pathman`](https://github.com/postgrespro/pg_pathman/wiki/Known-limitations),
656+
* All [limitations](https://github.com/postgrespro/pg_pathman/wiki/Known-limitations) (and some features) of `pg_pathman`,
644657
e.g. we don't support global primary keys and foreign keys to sharded tables.
645658
* All [limitations of logical replications](https://www.postgresql.org/docs/10/static/logical-replication-restrictions.html).
646659
`TRUNCATE` statements on sharded tables will not be replicated.

tests/python/tests.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@ def pt_replicas_integrity(self, required_replicas=None):
249249
DBNAME, sum_query(part_name))
250250
self.assertEqual(part_sum, replica_sum)
251251

252+
def pt_cleanup(self):
253+
self.lord.safe_psql(DBNAME, "select shardman.rm_table('pt')")
254+
self.lord.safe_psql(DBNAME, "drop table pt;")
255+
self.lord.destroy_cluster();
256+
252257
# tests
253258

254259
def test_add_node(self):
@@ -361,9 +366,7 @@ def test_set_redundancy(self):
361366
# must be exactly two replicas for each partition
362367
self.pt_replicas_integrity(required_replicas=2)
363368

364-
self.lord.safe_psql(DBNAME, "select shardman.rm_table('pt')")
365-
self.lord.safe_psql(DBNAME, "drop table pt;")
366-
self.lord.destroy_cluster()
369+
self.pt_cleanup()
367370

368371
def test_rebalance(self):
369372
self.lord.create_cluster(2, 2)
@@ -413,9 +416,7 @@ def test_rebalance(self):
413416
self.pt_everyone_sees_the_whole()
414417
self.pt_replicas_integrity()
415418

416-
self.lord.safe_psql(DBNAME, "select shardman.rm_table('pt')")
417-
self.lord.safe_psql(DBNAME, "drop table pt;")
418-
self.lord.destroy_cluster()
419+
self.pt_cleanup()
419420

420421
def test_deadlock_detector(self):
421422
self.lord.create_cluster(2)
@@ -486,7 +487,7 @@ def xact_2():
486487
try:
487488
with self.lord.connect() as con:
488489
con.execute("set statement_timeout = '3s'")
489-
con.execute("select shardman.monitor(deadlock_check_timeout_sec => 1)")
490+
con.execute("select shardman.monitor(check_timeout_sec => 1)")
490491
except:
491492
pass
492493
t1.join(5)
@@ -495,12 +496,11 @@ def xact_2():
495496
self.assertTrue(not t2.is_alive())
496497
self.assertTrue(xact_1_aborted or xact_2_aborted)
497498

498-
self.lord.safe_psql(DBNAME, "select shardman.rm_table('pt')")
499-
self.lord.safe_psql(DBNAME, "drop table pt;")
500-
self.lord.destroy_cluster();
499+
self.pt_cleanup()
501500

501+
# WIP
502502
def test_worker_failover(self):
503-
self.lord.create_cluster(3, 2)
503+
self.lord.create_cluster(2, 2)
504504
self.lord.safe_psql(
505505
DBNAME, 'create table pt(id int primary key, payload int default 1);')
506506
self.lord.safe_psql(

0 commit comments

Comments
 (0)