Skip to content

Commit 0335888

Browse files
committed
Fix global xmin calculation in DTM in case there are no active global transactions.
1 parent 7c03440 commit 0335888

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

contrib/pg_xtm/dtmd/src/main.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,17 @@ static void gen_snapshot(Transaction *t) {
227227

228228
static xid_t get_global_xmin() {
229229
int i, j;
230-
xid_t xmin = MAX_XID;
230+
xid_t xmin = INVALID_XID;
231231
Transaction *t;
232232
for (i = 0; i < transactions_count; i++) {
233233
t = transactions + i;
234-
j = t->snapshots_count > MAX_SNAPSHOTS_PER_TRANS ? MAX_SNAPSHOTS_PER_TRANS : t->snapshots_count;
235-
while (--j >= 0) {
236-
Snapshot* s = transaction_snapshot(t, j);
237-
if (s->xmin < xmin) {
238-
xmin = s->xmin;
239-
}
240-
// minor TODO: Use 'times_sent' to generate a bit greater xmin?
234+
j = t->snapshots_count > MAX_SNAPSHOTS_PER_TRANS ? MAX_SNAPSHOTS_PER_TRANS : t->snapshots_count;
235+
while (--j >= 0) {
236+
Snapshot* s = transaction_snapshot(t, j);
237+
if ((xmin == INVALID_XID) || (s->xmin < xmin)) {
238+
xmin = s->xmin;
239+
}
240+
// minor TODO: Use 'times_sent' to generate a bit greater xmin?
241241
}
242242
}
243243
return xmin;

0 commit comments

Comments
 (0)