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

Commitbe11fa2

Browse files
committed
Repair incorrect order of operations in GetNewTransactionId(). We must
complete ExtendCLOG() before advancing nextXid, so that if that routinefails, the next incoming transaction will try it again. Per troublereport from Christopher Kings-Lynne.
1 parent7a14a72 commitbe11fa2

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

‎src/backend/access/transam/varsup.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.54 2004/01/07 18:56:24 neilc Exp $
9+
* $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.55 2004/01/26 19:15:59 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -45,10 +45,8 @@ GetNewTransactionId(void)
4545

4646
xid=ShmemVariableCache->nextXid;
4747

48-
TransactionIdAdvance(ShmemVariableCache->nextXid);
49-
5048
/*
51-
* If wehave just allocated the first XID of a new page of the commit
49+
* If weare allocating the first XID of a new page of the commit
5250
* log, zero out that commit-log page before returning. We must do
5351
* this while holding XidGenLock, else another xact could acquire and
5452
* commit a later XID before we zero the page.Fortunately, a page of
@@ -57,6 +55,14 @@ GetNewTransactionId(void)
5755
*/
5856
ExtendCLOG(xid);
5957

58+
/*
59+
* Now advance the nextXid counter. This must not happen until after
60+
* we have successfully completed ExtendCLOG() --- if that routine fails,
61+
* we want the next incoming transaction to try it again. We cannot
62+
* assign more XIDs until there is CLOG space for them.
63+
*/
64+
TransactionIdAdvance(ShmemVariableCache->nextXid);
65+
6066
/*
6167
* Must set MyProc->xid before releasing XidGenLock. This ensures
6268
* that when GetSnapshotData calls ReadNewTransactionId, all active
@@ -74,7 +80,7 @@ GetNewTransactionId(void)
7480
*
7581
* A solution to the atomic-store problem would be to give each PGPROC
7682
* its own spinlock used only for fetching/storing that PGPROC's xid.
77-
* (SInvalLock would then mean primarily thatPROCs couldn't be added/
83+
* (SInvalLock would then mean primarily thatPGPROCs couldn't be added/
7884
* removed while holding the lock.)
7985
*/
8086
if (MyProc!=NULL)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp