Skip to content

Commit 99a60ea

Browse files
committed
Undo replacement of TransactionIdIsInProgress
2 parents c28682f + 26db353 commit 99a60ea

File tree

17 files changed

+102
-23
lines changed

17 files changed

+102
-23
lines changed

contrib/pg_gtm/dtmd/bin/dtmd

-21.4 KB
Binary file not shown.

contrib/pg_gtm/dtmd/src/clog.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ cid_t clog_advance(clog_t clog) {
215215
shout("failed to store the fresh gcid value\n");
216216
return INVALID_GCID;
217217
}
218+
#ifdef SYNC
218219
fsync(clog->fresh_fd);
220+
#endif
219221

220222
int oldf = GCID_TO_FILEID(old_gcid);
221223
int newf = GCID_TO_FILEID(clog->fresh_gcid);

contrib/pg_gtm/dtmd/src/clogfile.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,11 @@ bool clogfile_set_status(clogfile_t *clogfile, cid_t gcid, int status) {
9999
char *p = ((char*)clogfile->data + offset);
100100
*p &= ~(COMMIT_MASK << (BITS_PER_COMMIT * suboffset)); // AND-out the old status
101101
*p |= status << (BITS_PER_COMMIT * suboffset); // OR-in the new status
102+
#ifdef SYNC
102103
if (msync(clogfile->data, BYTES_PER_FILE, MS_SYNC)) {
103104
shout("cannot msync clog file '%s': %s\n", clogfile->path, strerror(errno));
104105
return false;
105106
}
107+
#endif
106108
return true;
107109
}

contrib/pg_gtm/dtmd/src/eventwrap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ static void on_connect(uv_stream_t *server, int status) {
7070
free(client);
7171
return;
7272
}
73+
uv_tcp_nodelay(client, 1);
7374
onconnect_cb(&client->data);
7475
uv_read_start((uv_stream_t*)client, on_alloc, on_read);
7576
}

contrib/pg_gtm/dtmd/src/main.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#define DEFAULT_LISTENHOST "0.0.0.0"
1313
#define DEFAULT_LISTENPORT 5431
1414

15-
#define MAX_PREPARES_PER_CLIENT 1024
15+
#define MAX_PREPARES_PER_CLIENT 1024*100
1616

1717
typedef struct client_data_t {
1818
int id;
@@ -83,13 +83,6 @@ static bool client_remove_prepare(void *client, cid_t gcid) {
8383
}
8484

8585
static char *onprepare(void *client, cmd_t *cmd) {
86-
if (CLIENT_PREPARES_NUM(client) >= MAX_PREPARES_PER_CLIENT) {
87-
shout(
88-
"[%d] cannot prepare any more commits\n",
89-
CLIENT_ID(client)
90-
);
91-
return strdup("-");
92-
}
9386

9487
cid_t gcid = clog_advance(clg);
9588
if (gcid == INVALID_GCID) {
@@ -101,48 +94,60 @@ static char *onprepare(void *client, cmd_t *cmd) {
10194
char buf[18];
10295
sprintf(buf, "+%016llx", gcid);
10396

97+
#ifdef VERBOSE
10498
shout(
10599
"[%d] prepare gcid %llx\n",
106100
CLIENT_ID(client), gcid
107101
);
102+
#endif
108103

109104
return strdup(buf);
110105
}
111106

112107
static char *oncommit(void *client, cmd_t *cmd) {
108+
#ifdef VERBOSE
113109
shout(
114110
"[%d] commit %016llx\n",
115111
CLIENT_ID(client),
116112
cmd->arg
117113
);
114+
#endif
115+
118116
if (clog_write(clg, cmd->arg, COMMIT_YES)) {
119117
if (client_remove_prepare(client, cmd->arg)) {
120118
return strdup("+");
121119
}
120+
#ifdef VERBOSE
122121
shout(
123122
"[%d] tried to commit an unprepared gcid %llu\n",
124123
CLIENT_ID(client),
125124
cmd->arg
126125
);
126+
#endif
127127
}
128128
return strdup("-");
129129
}
130130

131131
static char *onabort(void *client, cmd_t *cmd) {
132+
#ifdef VERBOSE
132133
shout(
133134
"[%d] abort %016llx\n",
134135
CLIENT_ID(client),
135136
cmd->arg
136137
);
138+
#endif
139+
137140
if (clog_write(clg, cmd->arg, COMMIT_NO)) {
138141
if (client_remove_prepare(client, cmd->arg)) {
139142
return strdup("+");
140143
}
144+
#ifdef VERBOSE
141145
shout(
142146
"[%d] tried to abort an unprepared gcid %016llx\n",
143147
CLIENT_ID(client),
144148
cmd->arg
145149
);
150+
#endif
146151
}
147152
return strdup("-");
148153
}

contrib/pg_gtm/libdtm.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
#include <unistd.h>
66
#include <stdlib.h>
77

8+
#ifdef __APPLE__
9+
#include <netinet/tcp.h>
10+
#endif
11+
812
#include "libdtm.h"
913

1014
typedef struct DTMConnData {
@@ -89,6 +93,9 @@ DTMConn DtmConnect(char *host, int port) {
8993
continue;
9094
}
9195

96+
int one = 1;
97+
setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one));
98+
9299
if (connect(sock, a->ai_addr, a->ai_addrlen) == -1) {
93100
perror("failed to connect to an address");
94101
close(sock);

contrib/pg_gtm/libdtm/Makefile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
CC=clang
22
CFLAGS=-g -Wall -I"../../../src/include"
33

4+
all: lib/libdtm.a bin/example bin/perf
45

5-
all: lib/libdtm.a bin/example
6+
bin/perf: bindir lib/libdtm.a src/perf.c
7+
$(CC) $(CFLAGS) -o bin/perf -Iinclude -Llib src/perf.c -ldtm
68

79
bin/example: bindir lib/libdtm.a src/example.c
810
$(CC) $(CFLAGS) -o bin/example -Iinclude -Llib src/example.c -ldtm
911

10-
lib/libdtm.a: libdir obj/dtm.o
11-
ar rcs lib/libdtm.a obj/dtm.o
12+
lib/libdtm.a: libdir obj/libdtm.o
13+
ar rcs lib/libdtm.a obj/libdtm.o
1214

13-
obj/dtm.o: objdir src/dtm.c
14-
$(CC) $(CFLAGS) -c -o obj/dtm.o -Iinclude src/dtm.c
15+
obj/libdtm.o: objdir src/libdtm.c
16+
$(CC) $(CFLAGS) -c -o obj/libdtm.o -Iinclude src/libdtm.c
1517

1618
libdir:
1719
mkdir -p lib

contrib/pg_gtm/libdtm/src/libdtm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../libdtm.c

contrib/pg_gtm/libdtm/src/libdtm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../libdtm.h

contrib/pg_gtm/libdtm/src/perf.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
4+
#include "../../libdtm.h"
5+
6+
int main() {
7+
cid_t gcid;
8+
cid_t horizon;
9+
DTMConn conn;
10+
int i;
11+
12+
conn = DtmConnect("localhost", 5431);
13+
if (!conn) {
14+
fprintf(stderr, "failed to connect to dtmd\n");
15+
exit(1);
16+
}
17+
18+
19+
for (i=0; i<10000; i++) {
20+
horizon = DtmGlobalGetNextCid(conn);
21+
22+
gcid = DtmGlobalPrepare(conn);
23+
if (gcid == INVALID_GCID) {
24+
fprintf(stderr, "failed to prepare a commit\n");
25+
}
26+
27+
if (!DtmGlobalCommit(conn, gcid)) {
28+
fprintf(stderr, "failed to commit gcid = %llu\n", gcid);
29+
}
30+
31+
if (i%100 == 0){
32+
printf("Completed %u txs\n", i);
33+
}
34+
}
35+
36+
37+
DtmDisconnect(conn);
38+
39+
return 0;
40+
}
41+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy