Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit21ffe4a

Browse files
committed
Revert "Optimize get_global_xmin"
This reverts commit504c5da.
1 parentc6e2135 commit21ffe4a

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

‎contrib/pg_dtm/dtmd/include/transaction.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ typedef struct L2List
2020
typedefstructTransaction {
2121
L2Listelem;
2222
xid_txid;
23-
xid_txmin;
2423

2524
intsize;// number of paritcipants
2625

‎contrib/pg_dtm/dtmd/src/main.c‎

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,19 @@ static void onreserve(client_t client, int argc, xid_t *argv) {
246246
}
247247

248248
staticxid_tget_global_xmin() {
249+
intj;
249250
xid_txmin=next_gxid;
250251
Transaction*t;
251252
for (t= (Transaction*)active_transactions.next;t!= (Transaction*)&active_transactions;t= (Transaction*)t->elem.next) {
252-
if (t->xmin<xmin) {
253-
xmin=t->xmin;
254-
}
255-
}
253+
j=t->snapshots_count>MAX_SNAPSHOTS_PER_TRANS ?MAX_SNAPSHOTS_PER_TRANS :t->snapshots_count;
254+
while (--j >=0) {
255+
Snapshot*s=transaction_snapshot(t,j);
256+
if (s->xmin<xmin) {
257+
xmin=s->xmin;
258+
}
259+
// minor TODO: Use 'times_sent' to generate a bit greater xmin?
260+
}
261+
}
256262
returnxmin;
257263
}
258264

@@ -277,6 +283,7 @@ static void onbegin(client_t client, int argc, xid_t *argv) {
277283
free_transactions=t->elem.next;
278284
}
279285
transaction_clear(t);
286+
l2_list_link(&active_transactions,&t->elem);
280287

281288
prev_gxid=t->xid=next_gxid++;
282289
t->snapshots_count=0;
@@ -292,15 +299,15 @@ static void onbegin(client_t client, int argc, xid_t *argv) {
292299
CLIENT_ID(client),t->xid
293300
);
294301
client_message_shortcut(client,RES_FAILED);
295-
free_transaction(t);
296302
return;
297303
}
304+
298305
xid_tgxmin=get_global_xmin();
299-
Snapshot*snap=transaction_next_snapshot(t);
300-
gen_snapshot(snap);// FIXME: increase 'times_sent' here? see also 4765234987
301306

302-
t->xmin=snap->xmin;
303-
l2_list_link(&active_transactions,&t->elem);
307+
gen_snapshot(transaction_next_snapshot(t));
308+
// will wrap around if exceeded max snapshots
309+
Snapshot*snap=transaction_latest_snapshot(t);
310+
// FIXME: increase 'times_sent' here? see also 4765234987
304311

305312
xid_tok=RES_OK;
306313
client_message_start(client); {
@@ -455,11 +462,7 @@ static void onsnapshot(client_t client, int argc, xid_t *argv) {
455462

456463
if (CLIENT_SNAPSENT(client)==t->snapshots_count) {
457464
// a fresh snapshot is needed
458-
Snapshot*snap=transaction_next_snapshot(t);
459-
gen_snapshot(snap);
460-
if (snap->xmin<t->xmin) {
461-
t->xmin=snap->xmin;
462-
}
465+
gen_snapshot(transaction_next_snapshot(t));
463466
}
464467

465468
xid_tgxmin=get_global_xmin();

‎contrib/pg_dtm/dtmd/src/transaction.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ void transaction_clear(Transaction *t) {
2727
inti;
2828

2929
t->xid=INVALID_XID;
30-
t->xmin=INVALID_XID;
3130
t->size=0;
3231
t->votes_for=0;
3332
t->votes_against=0;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp