@@ -36,40 +36,25 @@ dtm_get_snapshot() RETURNS void
36
36
libdtm api
37
37
----------
38
38
39
- typedef unsigned long long xid_t ;
39
+ void DtmInitSnapshot(Snapshot snapshot) ;
40
40
41
- typedef int NodeId;
41
+ // Starts new global transaction
42
+ TransactionId DtmGlobalStartTransaction(int nParticipants, Snapshot shaposhot);
42
43
43
- typedef struct {
44
- TransactionId* xids;
45
- NodeId* nodes;
46
- int nNodes;
47
- } GlobalTransactionId;
48
-
49
- // Connects to the specified DTM.
50
- DTMConn DtmConnect(char *host, int port);
51
-
52
- // Disconnects from the DTM. Do not use the 'dtm' pointer after this call, or
53
- // bad things will happen.
54
- void DtmDisconnect(DTMConn dtm);
55
-
56
- // Creates an entry for a new global transaction. Returns 'true' on success, or
57
- // 'false' otherwise.
58
- bool DtmGlobalStartTransaction(DTMConn dtm, GlobalTransactionId* gtid);
59
-
60
- // Asks DTM for a fresh snapshot. Returns 'true' on success, or 'false'
61
- // otherwise.
62
- bool DtmGlobalGetSnapshot(DTMConn dtm, NodeId nodeid, TransactionId xid, Snapshot snapshot);
44
+ // Get existed DTM snapshot.
45
+ void DtmGlobalGetSnapshot(TransactionId xid, Snapshot snapshot);
63
46
64
47
// Commits transaction only once all participants have called this function,
65
- // does not change CLOG otherwise. Returns 'true' on success, 'false' if
66
- // something failed on the daemon side.
67
- bool DtmGlobalSetTransStatus(DTMConn dtm, NodeId nodeid, TransactionId xid, XidStatus status);
48
+ // does not change CLOG otherwise.
49
+ void DtmGlobalSetTransStatus(TransactionId xid, XidStatus status, bool wait);
68
50
69
51
// Gets the status of the transaction identified by 'xid'. Returns the status
70
52
// on success, or -1 otherwise. If 'wait' is true, then it does not return
71
53
// until the transaction is finished.
72
- XidStatus DtmGlobalGetTransStatus(DTMConn dtm, NodeId nodeid, TransactionId xid, bool wait);
54
+ XidStatus DtmGlobalGetTransStatus(TransactionId xid, bool wait);
55
+
56
+ // Reserve XIDs for local transaction
57
+ TransactioinId DtmGlobalReserve(int nXids);
73
58
74
59
--------------------
75
60
Backend-DTM Protocol
@@ -85,56 +70,63 @@ The queries from backend to DTM should be formatted according to this syntax.
85
70
86
71
The commands:
87
72
88
- 'b': begin(size, node0, xid0, node1, xid1, ...)
89
- Starts a global transaction using 'xid0' on 'node0', 'xid1' on 'node1'
90
- and so on. The 'size' is the number of nodes, so for example if 'size'
91
- == 3 there are 6 values expected after it.
92
-
93
- The DTM replies with '+' if transaction started, or '-' if failed.
73
+ 'r': reserve(minxid, minsize)
74
+ Claims a sequence ≥ minsize of xids ≥ minxid for local usage. This will
75
+ prevent DTM from using those values for global transactions.
94
76
95
- 'c': commit(node, xid, wait)
96
- Tells the DTM to vote for commit of the global transaction identified
97
- by the given 'node:xid' pair.
77
+ The DTM replies with:
78
+ '+'<hex16 min><hex16 max> if reserved a range [min, max]
79
+ '-' on failure
98
80
99
- The DTM replies with '+' if committed, or '-' if aborted or failed.
81
+ 'b': begin(size)
82
+ Starts a global transaction and assign a 'xid' to it. 'size' is used
83
+ for vote results calculation. The DTM also creates and returns the
84
+ snapshot.
85
+
86
+ The DTM replies with:
87
+ '+'<hex16 xid><snapshot> if transaction started successfully
88
+ '-' on failure
89
+
90
+ See the 'snapshot' command description for the snapshot format.
91
+
92
+ 's': status(xid, wait)
93
+ Asks the DTM about the status of the global transaction identified
94
+ by the given 'xid'.
100
95
101
96
If 'wait' is true, DTM will not reply until it considers the
102
- transaction finished (all nodes committed, or at least one aborted).
97
+ transaction finished (all nodes voted, or one dead).
98
+
99
+ The DTM replies with:
100
+ "+0" if not started
101
+ "+c" if committed
102
+ "+a" if aborted
103
+ "+?" if in progress
104
+ '-' if failed
105
+
106
+ 'y': for(xid, wait)
107
+ Tells the DTM to vote for commit of the global transaction identified
108
+ by the given 'xid'.
109
+
110
+ The reply and 'wait' logic is the same as for the 'status' command.
103
111
104
- 'a ': abort(node, xid )
112
+ 'n ': against(xid, wait )
105
113
Tells the DTM to vote againts commit of the global transaction
106
- identified by the given 'node:xid' pair. This query not have the 'wait'
107
- parameter, because the DTM will not wait for all votes if one is
108
- against the commit.
109
-
110
- The DTM replies with '+' if aborted, or '-' if failed. The backend
111
- probably should ignore this reply anyway :)
112
-
113
- 'h': snapshot(node, xid)
114
- Tells the DTM to give a snapshot for the global transaction identified
115
- by the given 'node:xid' pair. The DTM will create a snapshot for every
116
- participant, so when they ask for the snapshot it will reply with the
117
- "same" snapshot. When a node asks for a snapshot once again, the DTM
118
- generates a fresh version for every participant. So be careful not to
119
- ask for a snapshot from the same node the second time, until all other
120
- nodes also ask for that snapshot.
114
+ identified by the given 'xid'.
121
115
122
- The DTM replies with '+' followed by a snapshot in the form:
116
+ The reply and 'wait' logic is the same as for the 'status' command.
123
117
124
- <hex16 xmin><hex16 xmax><hex16 xcnt><hex16 xip[0]>...
118
+ 'h': snapshot(xid)
119
+ Tells the DTM to generate a snapshot for the global transaction
120
+ identified by the given 'xid'. The DTM will create a snapshot for every
121
+ participant, so when each of them asks for the snapshot it will reply
122
+ with the same snapshot. The DTM generates a fresh version if the same
123
+ client asks for a snapshot again for the same transaction.
125
124
126
- In case of a failure, the DTM replies with '-'.
125
+ Joins the global transaction identified by the given 'xid', if not
126
+ joined already.
127
127
128
- 's': status(node, xid, wait)
129
- Asks the DTM about the status of the global transaction identified
130
- by the given 'node:xid' pair.
128
+ The DTM replies with '+' followed by a snapshot in the form:
131
129
132
- The DTM replies with:
133
- "+0" if not started;
134
- "+c" if committed;
135
- "+a" if aborted;
136
- "+?" if in progress;
137
- '-' if failed.
130
+ <hex16 xmin><hex16 xmax><hex16 xcnt><hex16 xip[0]>...
138
131
139
- If 'wait' is true, DTM will not reply until it considers the
140
- transaction finished (all nodes committed, or at least one aborted).
132
+ In case of a failure, the DTM replies with '-'.
0 commit comments