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

Commit7abbbb9

Browse files
committed
Optimize get_global_xmin
2 parents05ae2fb +21ffe4a commit7abbbb9

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

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

Lines changed: 12 additions & 10 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=t->xmin=next_gxid++;
282289
t->snapshots_count=0;
@@ -295,7 +302,6 @@ static void onbegin(client_t client, int argc, xid_t *argv) {
295302
free_transaction(t);
296303
return;
297304
}
298-
l2_list_link(&active_transactions,&t->elem);
299305

300306
xid_tgxmin=get_global_xmin();
301307
Snapshot*snap=transaction_next_snapshot(t);
@@ -455,11 +461,7 @@ static void onsnapshot(client_t client, int argc, xid_t *argv) {
455461

456462
if (CLIENT_SNAPSENT(client)==t->snapshots_count) {
457463
// 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-
}
464+
gen_snapshot(transaction_next_snapshot(t));
463465
}
464466

465467
xid_tgxmin=get_global_xmin();

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

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

2929
t->xid=INVALID_XID;
30-
t->xmin=INVALID_XID;
30+
t->xmin=INVALID_XID;
3131
t->size=0;
3232
t->votes_for=0;
3333
t->votes_against=0;

‎contrib/pg_dtm/sockhub/sockhub.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ void ShubLoop(Shub* shub)
254254
signal(SIGINT,die);
255255
signal(SIGQUIT,die);
256256
signal(SIGTERM,die);
257-
signal(SIGHUP,die);
257+
//signal(SIGHUP, die);
258258
sigset_tsset;
259259
sigfillset(&sset);
260260
sigprocmask(SIG_UNBLOCK,&sset,NULL);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp