Skip to content

Commit 9680a71

Browse files
committed
1. MyProc->xid assignment is moved to GetNewTransactionId so newer
transactions will not assume that MyProc transaction was committed before snapshot calculations. With old MyProc->xid assignment (in xact.c:StartTransaction()) there was ability to see the same row twice (I used gdb for this)!... 2. Assignments of InvalidTransactionId to MyProc->xid and MyProc->xmin are moved from xact.c:CommitTransaction() to xact.c:RecordTransactionCommit() - this invalidation must be done before releasing transaction locks or bad (too high) XmaxRecent value might be used by vacuum ("ERROR: Child itemid marked as unused" reported by "Hiroshi Inoue" <Inoue@tpf.co.jp>; once again, gdb allowed me reproduce this error).
1 parent f3d2b2e commit 9680a71

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/backend/access/transam/varsup.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.20 1999/05/25 16:07:48 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.21 1999/06/03 04:41:40 vadim Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -19,6 +19,7 @@
1919
#include <access/xact.h>
2020
#include <access/heapam.h>
2121
#include <catalog/catname.h>
22+
#include <storage/proc.h>
2223

2324
static void GetNewObjectIdBlock(Oid *oid_return, int oid_block_size);
2425
static void VariableRelationGetNextOid(Oid *oid_return);
@@ -308,6 +309,9 @@ GetNewTransactionId(TransactionId *xid)
308309
TransactionIdAdd(&(ShmemVariableCache->nextXid), 1);
309310
(ShmemVariableCache->xid_count)--;
310311

312+
if (MyProc != (PROC *) NULL)
313+
MyProc->xid = *xid;
314+
311315
SpinRelease(OidGenLockId);
312316
}
313317

src/backend/access/transam/xact.c

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.37 1999/05/31 22:53:59 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.38 1999/06/03 04:41:41 vadim Exp $
1111
*
1212
* NOTES
1313
* Transaction aborts can now occur two ways:
@@ -646,6 +646,18 @@ RecordTransactionCommit()
646646
FlushBufferPool(!TransactionFlushEnabled());
647647
if (leak)
648648
ResetBufferPool();
649+
650+
/*
651+
* Let others know about no transaction in progress.
652+
* Note that this must be done _before_ releasing locks
653+
* we hold or bad (too high) XmaxRecent value might be
654+
* used by vacuum.
655+
*/
656+
if (MyProc != (PROC *) NULL)
657+
{
658+
MyProc->xid = InvalidTransactionId;
659+
MyProc->xmin = InvalidTransactionId;
660+
}
649661
}
650662

651663

@@ -884,13 +896,6 @@ StartTransaction()
884896
*/
885897
s->state = TRANS_INPROGRESS;
886898

887-
/*
888-
* Let others to know about current transaction is in progress - vadim
889-
* 11/26/96
890-
*/
891-
if (MyProc != (PROC *) NULL)
892-
MyProc->xid = s->transactionIdData;
893-
894899
}
895900

896901
/* ---------------
@@ -958,15 +963,6 @@ CommitTransaction()
958963
*/
959964
s->state = TRANS_DEFAULT;
960965

961-
/*
962-
* Let others to know about no transaction in progress - vadim
963-
* 11/26/96
964-
*/
965-
if (MyProc != (PROC *) NULL)
966-
{
967-
MyProc->xid = InvalidTransactionId;
968-
MyProc->xmin = InvalidTransactionId;
969-
}
970966
}
971967

972968
/* --------------------------------

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy