Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit45334b9

Browse files
committed
README update
1 parenta2ec174 commit45334b9

File tree

1 file changed

+96
-31
lines changed

1 file changed

+96
-31
lines changed

‎README.md‎

Lines changed: 96 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,113 @@
1-
0) Design
1+
#pg_dtm
22

3-
General concept oberview. wiki link. This repo implements Snapshot Sharing mechnism.
4-
Protocol description. README.protocol
5-
Presentation
3+
###Design
64

7-
1) Installing
5+
This repo implements distributed transaction manager using Snapshot Sharing mechanism. General concepts and alternative approaches described in postgres wikihttps://wiki.postgresql.org/wiki/DTM.
86

9-
* patch postgres
10-
* install extension
11-
* configure two postgreses
12-
* run dtmd
13-
* run postgreses
7+
Backend-DTM protocol description can be found in[dtmd/README](dtmd/README).
148

15-
1b) Automatic provisioning
9+
###Installation
1610

17-
* For a wide deploy we use ansible. Layouts/Farms. More details later.
18-
19-
2) Usage
11+
* Patch postgres using xtm.patch. After that build and install postgres in usual way.
12+
```bash
13+
cd~/code/postgres
14+
patch -p1<~/code/pg_dtm/xtm.patch
15+
```
16+
* Install pg_dtm extension.
17+
```bash
18+
export PATH=/path/to/pgsql/bin/:$PATH
19+
cd~/code/pg_dtm
20+
make&& make install
21+
```
22+
* Run dtmd.
23+
```bash
24+
cd~/code/pg_dtm/dtmd
25+
make
26+
./bin/dtmd&
27+
```
28+
* To run something meaningful you need at leat two postgres instances. Also pg_dtm requires
29+
```bash
30+
initdb -D ./install/data1
31+
initdb -D ./install/data2
32+
echo"port = 5433">> ./install/data2/postgresql.conf
33+
echo"shared_preload_libraries = 'pg_dtm'">> ./install/data1/postgresql.conf
34+
echo"shared_preload_libraries = 'pg_dtm'">> ./install/data2/postgresql.conf
35+
pg_ctl -D ./install/data1 -l ./install/data1/log start
36+
pg_ctl -D ./install/data2 -l ./install/data2/log start
37+
```
2038

21-
now you can use global tx between this two nodes
39+
####Automatic provisioning
2240

23-
table with two columns
24-
```sql
25-
example
26-
```
41+
For a cluster-wide deploy we use ansible, more details in tests/deploy_layouts. (Ansible instructions will be later)
2742

28-
3) Consistency testing
43+
###Usage
2944

30-
To ensure consistency we use simple bank test: perform a lot of simultaneous transfersbetweenaccounts on different servers, while constantly checking total amount of money on all accounts.
45+
Now cluster is running and you can use global txbetweentwo nodes.
3146

32-
go run ...
3347

34-
also there is the test for measuring select performance.
48+
```sql
49+
create extension pg_dtm;-- node1
50+
create extension pg_dtm;-- node2
51+
select dtm_begin_transaction();-- node1, returns global xid, e.g. 42
52+
select dtm_join_transaction(42);-- node2, join global tx
53+
begin;-- node1
54+
begin;-- node2
55+
update accountsset amount=amount-100where user_id=1;-- node1, transfer money from user#1
56+
update accountsset amount=amount+100where user_id=2;-- node2, to user#2
57+
commit;-- node1
58+
commit;-- node2
59+
```
3560

36-
4) Using with fdw.
61+
###Consistency testing
62+
63+
To ensure consistency we use simple bank test: perform a lot of simultaneous transfers between accounts on different servers, while constantly checking total amount of money on all accounts. This test can be found in tests/perf.
64+
65+
```bash
66+
> go run ./perf/*
67+
-C value
68+
Connection string (repeatfor multiple connections)
69+
-a int
70+
The number of bank accounts (default 100000)
71+
-b string
72+
Backend to use. Possible optinos: transfers, fdw, pgshard, readers. (default"transfers")
73+
-gUse DTM to keep global consistency
74+
-iInit database
75+
-lUse'repeatable read' isolation level instead of'read committed'
76+
-n int
77+
The number updates each writer (readerincase of Reades backend) performs (default 10000)
78+
-pUse parallel execs
79+
-r int
80+
The number of readers (default 1)
81+
-s int
82+
StartID. Script will update rows starting from this value
83+
-vShow progress and other stufffor mortals
84+
-w int
85+
The number of writers (default 8)
86+
```
3787
38-
patch
39-
go run ...
88+
So previous installation can be initialized with:
89+
```
90+
go run ./perf/*.go \
91+
-C"dbname=postgres port=5432" \
92+
-C"dbname=postgres port=5433" \
93+
-g -i
94+
```
95+
and tested with:
96+
```
97+
go run ./perf/*.go \
98+
-C"dbname=postgres port=5432" \
99+
-C"dbname=postgres port=5433" \
100+
-g
101+
```
40102
41-
5) Using withpg_shard
103+
### Using withpostres_fdw.
42104
43-
checkout repo
44-
go run ...
105+
We also provide a patch, that enables support of global transactions with postres_fdw. After patching and installing postres_fdw it is possible to run sametest via fdw usig key```-b fdw```.
45106
46-
6) Results
107+
### Using with pg_shard
47108
48-
Some graphs
109+
Citus Data have branchin their pg_shard repo, that interacts with transaction manager. https://github.com/citusdata/pg_shard/tree/transaction_manager_integration
110+
To use this feature one should have following linein postgresql.conf (orset it via GUC)
111+
```
112+
pg_shard.use_dtm_transactions = 1
113+
```

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp