forked from postgrespro/pg_tsdtm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
89 lines (66 loc) · 2.44 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
===
dtm
===
Distributed transaction management tools for PostgreSQL.
--------------------
Communication scheme
--------------------
.- Backend -.
/ \
/ \
DTM ---- Backend ---- Coordinator
\ /
\ /
`- Backend -´
-----------------------
Coordinator-Backend API
-----------------------
This API includes a set of postgres procedures that
the coordinator can call with "select" statement.
extend_transaction (n integer) -> (higcid gcid)
join_transaction (higcid gcid) -> ()
FIXME: add procedures that would start and finish 2pc
----------
libdtm api
----------
typedef unsigned long long cid_t;
// Connects to the specified DTM.
DTMConn DtmConnect(char *host, int port);
// Disconnects from the DTM. Do not use the 'dtm' pointer after this call, or
// bad things will happen.
void DtmDisconnect(DTMConn dtm);
// Asks DTM for the first 'gcid' with unknown status. This 'gcid' is used as a
// kind of snapshot. Returns the 'gcid' on success, or INVALID_GCID otherwise.
cid_t DtmGlobalGetNextCid(DTMConn dtm);
// Prepares a commit. Returns the 'gcid' on success, or INVALID_GCID otherwise.
cid_t DtmGlobalPrepare(DTMConn dtm);
// Finishes a given commit with 'committed' status. Returns 'true' on success,
// 'false' otherwise.
bool DtmGlobalCommit(DTMConn dtm, cid_t gcid);
// Finishes a given commit with 'aborted' status.
void DtmGlobalRollback(DTMConn dtm, cid_t gcid);
// Gets the status of the commit identified by 'gcid'. Returns the status on
// success, or -1 otherwise.
int DtmGlobalGetTransStatus(DTMConn dtm, cid_t gcid);
--------------------
Backend-DTM Protocol
--------------------
DTM <--> Backend:
<- 'p'<hex16 self> - "prepare"
-> '+'<hex16 gcid> - "commit prepared"
-> '-' - "something went wrong"
<- 'c'<hex16 gcid> - "commit"
-> '+' - "commit saved"
-> '-' - "something went wrong"
<- 'a'<hex16 gcid> - "abort"
-> '+' - "abort saved"
-> '-' - "something went wrong"
<- 'h' - "horizon"
-> '+'<hex16 gcid> - "here is a gcid you can use as a snapshot"
-> '-' - "something went wrong"
<- 's'<hex16 gcid> - "status"
-> '+''c|a|?' - "here is the transaction status"
(c)ommitted, (a)borted or (?)unknown
-> '-' - "something went wrong"
Backend disconnection is considered as an abort of all incomplete commits
prepared by that backend.