1
1
===
2
- dtm
2
+ xtm
3
3
===
4
4
5
5
Distributed transaction management tools for PostgreSQL.
@@ -32,30 +32,37 @@ libdtm api
32
32
33
33
typedef unsigned long long xid_t;
34
34
35
+ typedef int NodeId;
36
+
37
+ typedef struct {
38
+ TransactionId* xids;
39
+ NodeId* nodes;
40
+ int nNodes;
41
+ } GlobalTransactionId;
42
+
35
43
// Connects to the specified DTM.
36
44
DTMConn DtmConnect(char *host, int port);
37
45
38
46
// Disconnects from the DTM. Do not use the 'dtm' pointer after this call, or
39
47
// bad things will happen.
40
48
void DtmDisconnect(DTMConn dtm);
41
49
42
- // Asks DTM for a fresh snapshot. Returns a snapshot on success, or NULL
43
- // otherwise. Please free the snapshot memory yourself after use.
44
- Snapshot DtmGlobalGetSnapshot(DTMConn dtm);
45
-
46
- // Starts a transaction. Returns the 'gxid' on success, or INVALID_GXID otherwise.
47
- xid_t DtmGlobalBegin(DTMConn dtm);
48
-
49
- // Marks a given transaction as 'committed'. Returns 'true' on success,
50
+ // Creates an entry for a new global transaction. Returns 'true' on success, or
50
51
// 'false' otherwise.
51
- bool DtmGlobalCommit(DTMConn dtm, xid_t gxid);
52
+ bool DtmGlobalStartTransaction(DTMConn dtm, GlobalTransactionId* gtid);
53
+
54
+ // Asks DTM for a fresh snapshot. Returns 'true' on success, or 'false'
55
+ // otherwise.
56
+ bool DtmGlobalGetSnapshot(DTMConn dtm, NodeId nodeid, TransactionId xid, Snapshot snapshot);
52
57
53
- // Marks a given transaction as 'aborted'.
54
- void DtmGlobalRollback(DTMConn dtm, xid_t gxid);
58
+ // Commits transaction only once all participants have called this function,
59
+ // does not change CLOG otherwise. Returns 'true' on success, 'false' if
60
+ // something failed on the daemon side.
61
+ bool DtmGlobalSetTransStatus(DTMConn dtm, NodeId nodeid, TransactionId xid, XidStatus status);
55
62
56
- // Gets the status of the transaction identified by 'gxid '. Returns the status
63
+ // Gets the status of the transaction identified by 'xid '. Returns the status
57
64
// on success, or -1 otherwise.
58
- int DtmGlobalGetTransStatus(DTMConn dtm, xid_t gxid );
65
+ XidStatus DtmGlobalGetTransStatus(DTMConn dtm, NodeId nodeid, TransactionId xid );
59
66
60
67
--------------------
61
68
Backend-DTM Protocol
@@ -80,11 +87,8 @@ DTM <--> Backend:
80
87
-> '-' - "something went wrong"
81
88
82
89
<- 's'<hex16 gxid> - "status"
83
- -> '+''c|a|?' - "here is the transaction status"
84
- (c)ommitted , (a)borted or (?)unknown
90
+ -> '+''0| c|a|?' - "here is the transaction status"
91
+ (0)unknown, (c)committed , (a)aborted, or (?)inprogress
85
92
-> '-' - "something went wrong"
86
93
87
94
<snapshot> = <hex16 xmin><hex16 xmax><hex16 n><hex16 active[n]>
88
-
89
- Backend disconnection is considered as an abort of all incomplete transactions
90
- started by that backend.
0 commit comments