Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c5c4be4

Browse files
committed
Avoid sort in DTMD
1 parent e25ebfb commit c5c4be4

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

contrib/pg_dtm/dtmd/src/main.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,24 +193,25 @@ static xid_t max(xid_t a, xid_t b) {
193193

194194
static void gen_snapshot(Snapshot *s) {
195195
Transaction* t;
196+
int n = 0;
196197
s->times_sent = 0;
197-
s->nactive = 0;
198-
s->xmin = MAX_XID;
199-
s->xmax = MIN_XID;
200-
for (t = (Transaction*)active_transactions.next; t != (Transaction*)&active_transactions; t = (Transaction*)t->elem.next) {
198+
for (t = (Transaction*)active_transactions.prev; t != (Transaction*)&active_transactions; t = (Transaction*)t->elem.prev) {
199+
/*
201200
if (t->xid < s->xmin) {
202201
s->xmin = t->xid;
203202
}
204203
if (t->xid >= s->xmax) {
205204
s->xmax = t->xid + 1;
206205
}
207-
s->active[s->nactive++] = t->xid;
206+
*/
207+
s->active[n++] = t->xid;
208208
}
209-
if (s->nactive > 0) {
210-
assert(s->xmin < MAX_XID);
211-
assert(s->xmax > MIN_XID);
209+
s->nactive = n;
210+
if (n > 0) {
211+
s->xmin = s->active[0];
212+
s->xmax = s->active[n-1];
212213
assert(s->xmin <= s->xmax);
213-
snapshot_sort(s);
214+
// snapshot_sort(s);
214215
} else {
215216
s->xmin = s->xmax = 0;
216217
}

0 commit comments

Comments
 (0)