* Copyright (c) 2000, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.51 2002/09/04 20:31:13 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.51.2.1 2004/01/26 19:16:40 tgl Exp $
*
*-------------------------------------------------------------------------
*/
xid = ShmemVariableCache->nextXid;
- TransactionIdAdvance(ShmemVariableCache->nextXid);
-
/*
- * If we have just allocated the first XID of a new page of the commit
+ * If we are allocating the first XID of a new page of the commit
* log, zero out that commit-log page before returning. We must do
* this while holding XidGenLock, else another xact could acquire and
* commit a later XID before we zero the page. Fortunately, a page of
*/
ExtendCLOG(xid);
+ /*
+ * Now advance the nextXid counter. This must not happen until after
+ * we have successfully completed ExtendCLOG() --- if that routine fails,
+ * we want the next incoming transaction to try it again. We cannot
+ * assign more XIDs until there is CLOG space for them.
+ */
+ TransactionIdAdvance(ShmemVariableCache->nextXid);
+
/*
* Must set MyProc->xid before releasing XidGenLock. This ensures
* that when GetSnapshotData calls ReadNewTransactionId, all active
*
* A solution to the atomic-store problem would be to give each PGPROC
* its own spinlock used only for fetching/storing that PGPROC's xid.
- * (SInvalLock would then mean primarily that PROCs couldn't be added/
+ * (SInvalLock would then mean primarily that PGPROCs couldn't be added/
* removed while holding the lock.)
*/
if (MyProc != (PGPROC *) NULL)