8000 Actualize DTM bench. · postgrespro/postgres_cluster@2e18a4d · GitHub
[go: up one dir, main page]

Skip to content

Commit 2e18a4d

Browse files
committed
Actualize DTM bench.
1 parent b64af78 commit 2e18a4d

File tree

1 file changed

+17
-25
lines changed

1 file changed

+17
-25
lines changed

contrib/pg_dtm/libdtm/src/bench.c

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,31 @@
66

77
#define unless(x) if (!(x))
88

9-
#define NODES 1
10-
11-
129
int main(int argc, char **argv) {
13-
GlobalTransactionId gtid;
14-
TransactionId base = 42;
15-
int transactions = 10000;
16-
int i;
17-
gtid.nNodes = NODES;
18-
gtid.xids = malloc(sizeof(TransactionId) * gtid.nNodes);
19-
gtid.nodes = malloc(sizeof(NodeId) * gtid.nNodes);
20-
21-
DTMConn conn = DtmConnect("localhost", 5431);
22-
if (!conn) {
23-
exit(1);
24-
}
10+
DtmGlobalConfig("localhost", 5002, "/tmp");
2511

12+
int i;
2613
for (i = 0; i < transactions; i++) {
27-
28-
int n;
29-
for (n = 0; n < gtid.nNodes; n++) {
30-
gtid.xids[n] = base + n;
31-
gtid.nodes[n] = n;
14+
TransactionId xid, gxmin;
15+
Snapshot snapshot;
16+
xid = DtmGlobalStartTransaction(snapshot, &gxmin);
17+
if (xid == INVALID_XID) {
18+
fprintf(stdout, "global transaction not started\n");
19+
exit(EXIT_FAILURE);
3220
}
3321

34-
if (!DtmGlobalStartTransaction(conn, &gtid)) {
35-
fprintf(stdout, "global transaction not started\n");
22+
DtmGlobalGetSnapshot(xid, snapshot, &gxmin);
23+
24+
bool wait = true;
25+
26+
XidStatus s = DtmGlobalSetTransStatus(xid, TRANSACTION_STATUS_COMMITTED, wait);
27+
if (s != TRANSACTION_STATUS_COMMITTED) {
28+
fprintf(stdout, "global transaction not committed\n");
3629
exit(EXIT_FAILURE);
3730
}
3831

39-
if (!DtmGlobalSetTransStatus(conn, 0, base + 0, TRANSACTION_STATUS_COMMITTED)) {
32+
s = DtmGlobalGetTransStatus(xid, wait);
33+
if (s != TRANSACTION_STATUS_COMMITTED) {
4034
fprintf(stdout, "global transaction not committed\n");
4135
exit(EXIT_FAILURE);
4236
}
@@ -48,7 +42,5 @@ int main(int argc, char **argv) {
4842
base++;
4943
}
5044

51-
52-
DtmDisconnect(conn);
5345
return EXIT_SUCCESS;
5446
}

0 commit comments

Comments
 (0)
0