Skip to content

Commit 63ae071

Browse files
committed
Sticky routing
1 parent d2f859b commit 63ae071

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

docs/features/sharding/omnishards.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,40 @@ Writing data to omnisharded tables is atomic if you enabled [two-phase commit](2
3434

3535
If you can't or choose not to use 2pc, make sure writes to omnisharded tables can be repeated in case of failure. This can be achieved by using unique indexes and `INSERT ... ON CONFLICT ... DO UPDATE` queries.
3636

37-
Since reads from omnisharded tables are routed to individual shards, while two-phase commit takes place, queries to these tables may return different results for a brief period of time.
37+
Since reads from omnisharded tables are routed to individual shards, while a two-phase commit takes place, queries to these tables may return different results for a brief period of time.
38+
39+
### Sticky routing
40+
41+
While most omnisharded tables should be identical on all shards, others could differ in subtle ways.
42+
43+
For example, if you configure system catalogs as omnisharded, e.g. to make Rails or other ORMs work out of the box, round robin query routing will return different results for each query.
44+
45+
When enabled, sticky routing will ensure that queries sent by a client to omnisharded tables will be consistently routed to the same shard, for the duration of the client connection.
46+
47+
To enable it, configure your omnisharded tables as follows:
48+
49+
```toml
50+
[[omnisharded_tables]]
51+
database = "prod"
52+
sticky = true # Enable sticky routing for the following tables.
53+
tables = [
54+
"pg_class",
55+
"pg_attribute",
56+
"pg_attrdef",
57+
"pg_index",
58+
"pg_constraint",
59+
"pg_namespace",
60+
"pg_database",
61+
"pg_tablespace",
62+
"pg_type",
63+
"pg_proc",
64+
"pg_operator",
65+
"pg_cast",
66+
"pg_enum",
67+
"pg_range",
68+
"pg_authid",
69+
"pg_am",
70+
]
71+
```
72+
73+
Once configured, commands like `\d`, `\d+` and others sent from `psql` will start to return correct results.

0 commit comments

Comments
 (0)