Skip to content

Commit fcd31f3

Browse files
committed
Use window for snapshots in DTMD
1 parent 9bbb357 commit fcd31f3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

contrib/pg_xtm/dtmd/src/main.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,8 @@ static void gen_snapshot(Snapshot *s, int node) {
332332

333333
static void gen_snapshots(GlobalTransaction *gt) {
334334
int n;
335-
assert(gt->n_snapshots < MAX_SNAPSHOTS_PER_TRANS);
336335
for (n = 0; n < MAX_NODES; n++) {
337-
gen_snapshot(&gt->participants[n].snapshot[gt->n_snapshots], n);
336+
gen_snapshot(&gt->participants[n].snapshot[gt->n_snapshots % MAX_SNAPSHOTS_PER_TRANS], n);
338337
}
339338
gt->n_snapshots += 1;
340339
}
@@ -380,7 +379,7 @@ static char *onsnapshot(void *stream, void *clientdata, cmd_t *cmd) {
380379
}
381380
assert(t->snapshot_no < gt->n_snapshots);
382381

383-
return snapshot_serialize(&t->snapshot[t->snapshot_no++]);
382+
return snapshot_serialize(&t->snapshot[t->snapshot_no++ % MAX_SNAPSHOTS_PER_TRANS]);
384383
}
385384

386385
static bool queue_for_transaction_finish(void *stream, void *clientdata, int node, xid_t xid, char cmd) {

contrib/pg_xtm/pg_dtm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,13 @@ static void DtmEnsureConnection(void)
6868
XTM_TRACE("XTM: DtmEnsureConnection\n");
6969
while (attempt < XTM_CONNECT_ATTEMPTS) {
7070
if (DtmConn) {
71-
break;
71+
return;
7272
}
7373
XTM_TRACE("XTM: DtmEnsureConnection, attempt #%u\n", attempt);
7474
DtmConn = DtmConnect("127.0.0.1", 5431);
7575
attempt++;
7676
}
77+
elog(ERROR, "Failed to connect to DTMD");
7778
}
7879

7980
static void DumpSnapshot(Snapshot s, char *name)

0 commit comments

Comments
 (0)