Skip to content

Commit bca1495

Browse files
committed
Add a snapshot dumping function into pg_dtm for debugging.
1 parent 5f7cb5f commit bca1495

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

contrib/pg_xtm/libdtm.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,11 @@ bool DtmGlobalGetSnapshot(DTMConn dtm, NodeId nodeid, TransactionId xid, Snapsho
233233
Assert(s->xip[i] == number); // the number should fit into xip[i] size
234234
}
235235

236-
fprintf(stdout, "snapshot: xmin = %#x, xmax = %#x, active =", s->xmin, s->xmax);
237-
for (i = 0; i < s->xcnt; i++) {
238-
fprintf(stdout, " %#x", s->xip[i]);
239-
}
240-
fprintf(stdout, "\n");
236+
//fprintf(stdout, "snapshot: xmin = %#x, xmax = %#x, active =", s->xmin, s->xmax);
237+
//for (i = 0; i < s->xcnt; i++) {
238+
// fprintf(stdout, " %#x", s->xip[i]);
239+
//}
240+
//fprintf(stdout, "\n");
241241

242242
return true;
243243
}

contrib/pg_xtm/pg_dtm.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,27 @@ static void DtmEnsureConnection(void)
7070
}
7171
}
7272

73+
static void DumpSnapshot(Snapshot s, char *name)
74+
{
75+
int i;
76+
char buf[10000];
77+
char *cursor = buf;
78+
cursor += sprintf(
79+
cursor,
80+
"snapshot %s: xmin=%d, xmax=%d, active=[",
81+
name, s->xmin, s->xmax
82+
);
83+
for (i = 0; i < s->xcnt; i++) {
84+
if (i == 0) {
85+
cursor += sprintf(cursor, "%d", s->xip[i]);
86+
} else {
87+
cursor += sprintf(cursor, ", %d", s->xip[i]);
88+
}
89+
}
90+
cursor += sprintf(cursor, "]");
91+
XTM_TRACE("%s\n", buf);
92+
}
93+
7394
static void DtmCopySnapshot(Snapshot dst, Snapshot src)
7495
{
7596
int i, j, n;

0 commit comments

Comments
 (0)