Remove NEXTXID xlog record type to avoid three-way deadlock risk.

NEXTXID isn't really necessary, per previous discussion in pghackers,
but I mulishy insisted we should put it in anyway.  Mea culpa.
This commit is contained in:
Tom Lane 2001-03-18 20:18:59 +00:00
parent ddc5bc958a
commit af6e88a9cf
7 changed files with 12 additions and 67 deletions

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.40 2001/03/13 01:17:05 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.41 2001/03/18 20:18:59 tgl Exp $
* *
* NOTES * NOTES
* This file contains the high level access-method interface to the * This file contains the high level access-method interface to the
@ -430,7 +430,6 @@ InitializeTransactionLog(void)
Assert(!IsUnderPostmaster && Assert(!IsUnderPostmaster &&
ShmemVariableCache->nextXid <= FirstTransactionId); ShmemVariableCache->nextXid <= FirstTransactionId);
ShmemVariableCache->nextXid = FirstTransactionId; ShmemVariableCache->nextXid = FirstTransactionId;
ShmemVariableCache->xidCount = 0; /* force an XLOG rec right away */
} }
else if (RecoveryCheckingEnabled()) else if (RecoveryCheckingEnabled())
{ {

View File

@ -6,7 +6,7 @@
* Copyright (c) 2000, PostgreSQL Global Development Group * Copyright (c) 2000, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.36 2001/03/13 01:17:05 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.37 2001/03/18 20:18:59 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -44,17 +44,9 @@ GetNewTransactionId(TransactionId *xid)
SpinAcquire(XidGenLockId); SpinAcquire(XidGenLockId);
/* If we run out of logged for use xids then we must log more */
if (ShmemVariableCache->xidCount == 0)
{
XLogPutNextXid(ShmemVariableCache->nextXid + VAR_XID_PREFETCH);
ShmemVariableCache->xidCount = VAR_XID_PREFETCH;
}
*xid = ShmemVariableCache->nextXid; *xid = ShmemVariableCache->nextXid;
(ShmemVariableCache->nextXid)++; (ShmemVariableCache->nextXid)++;
(ShmemVariableCache->xidCount)--;
SpinRelease(XidGenLockId); SpinRelease(XidGenLockId);

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.61 2001/03/18 00:30:27 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.62 2001/03/18 20:18:59 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -2161,7 +2161,6 @@ BootStrapXLOG(void)
checkPoint.time = time(NULL); checkPoint.time = time(NULL);
ShmemVariableCache->nextXid = checkPoint.nextXid; ShmemVariableCache->nextXid = checkPoint.nextXid;
ShmemVariableCache->xidCount = 0;
ShmemVariableCache->nextOid = checkPoint.nextOid; ShmemVariableCache->nextOid = checkPoint.nextOid;
ShmemVariableCache->oidCount = 0; ShmemVariableCache->oidCount = 0;
@ -2317,7 +2316,6 @@ StartupXLOG(void)
elog(STOP, "Invalid NextTransactionId/NextOid"); elog(STOP, "Invalid NextTransactionId/NextOid");
ShmemVariableCache->nextXid = checkPoint.nextXid; ShmemVariableCache->nextXid = checkPoint.nextXid;
ShmemVariableCache->xidCount = 0;
ShmemVariableCache->nextOid = checkPoint.nextOid; ShmemVariableCache->nextOid = checkPoint.nextOid;
ShmemVariableCache->oidCount = 0; ShmemVariableCache->oidCount = 0;
@ -2368,11 +2366,7 @@ StartupXLOG(void)
do do
{ {
if (record->xl_xid >= ShmemVariableCache->nextXid) if (record->xl_xid >= ShmemVariableCache->nextXid)
{
/* This probably shouldn't happen... */
ShmemVariableCache->nextXid = record->xl_xid + 1; ShmemVariableCache->nextXid = record->xl_xid + 1;
ShmemVariableCache->xidCount = 0;
}
if (XLOG_DEBUG) if (XLOG_DEBUG)
{ {
char buf[8192]; char buf[8192];
@ -2717,8 +2711,6 @@ CreateCheckPoint(bool shutdown)
SpinAcquire(XidGenLockId); SpinAcquire(XidGenLockId);
checkPoint.nextXid = ShmemVariableCache->nextXid; checkPoint.nextXid = ShmemVariableCache->nextXid;
if (!shutdown)
checkPoint.nextXid += ShmemVariableCache->xidCount;
SpinRelease(XidGenLockId); SpinRelease(XidGenLockId);
SpinAcquire(OidGenLockId); SpinAcquire(OidGenLockId);
@ -2803,21 +2795,6 @@ CreateCheckPoint(bool shutdown)
END_CRIT_SECTION(); END_CRIT_SECTION();
} }
/*
* Write a NEXTXID log record
*/
void
XLogPutNextXid(TransactionId nextXid)
{
XLogRecData rdata;
rdata.buffer = InvalidBuffer;
rdata.data = (char *)(&nextXid);
rdata.len = sizeof(TransactionId);
rdata.next = NULL;
(void) XLogInsert(RM_XLOG_ID, XLOG_NEXTXID, &rdata);
}
/* /*
* Write a NEXTOID log record * Write a NEXTOID log record
*/ */
@ -2841,18 +2818,7 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
{ {
uint8 info = record->xl_info & ~XLR_INFO_MASK; uint8 info = record->xl_info & ~XLR_INFO_MASK;
if (info == XLOG_NEXTXID) if (info == XLOG_NEXTOID)
{
TransactionId nextXid;
memcpy(&nextXid, XLogRecGetData(record), sizeof(TransactionId));
if (ShmemVariableCache->nextXid < nextXid)
{
ShmemVariableCache->nextXid = nextXid;
ShmemVariableCache->xidCount = 0;
}
}
else if (info == XLOG_NEXTOID)
{ {
Oid nextOid; Oid nextOid;
@ -2870,7 +2836,6 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
memcpy(&checkPoint, XLogRecGetData(record), sizeof(CheckPoint)); memcpy(&checkPoint, XLogRecGetData(record), sizeof(CheckPoint));
/* In a SHUTDOWN checkpoint, believe the counters exactly */ /* In a SHUTDOWN checkpoint, believe the counters exactly */
ShmemVariableCache->nextXid = checkPoint.nextXid; ShmemVariableCache->nextXid = checkPoint.nextXid;
ShmemVariableCache->xidCount = 0;
ShmemVariableCache->nextOid = checkPoint.nextOid; ShmemVariableCache->nextOid = checkPoint.nextOid;
ShmemVariableCache->oidCount = 0; ShmemVariableCache->oidCount = 0;
} }
@ -2879,11 +2844,10 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
CheckPoint checkPoint; CheckPoint checkPoint;
memcpy(&checkPoint, XLogRecGetData(record), sizeof(CheckPoint)); memcpy(&checkPoint, XLogRecGetData(record), sizeof(CheckPoint));
/* In an ONLINE checkpoint, treat the counters like NEXTXID/NEXTOID */ /* In an ONLINE checkpoint, treat the counters like NEXTOID */
if (ShmemVariableCache->nextXid < checkPoint.nextXid) if (ShmemVariableCache->nextXid < checkPoint.nextXid)
{ {
ShmemVariableCache->nextXid = checkPoint.nextXid; ShmemVariableCache->nextXid = checkPoint.nextXid;
ShmemVariableCache->xidCount = 0;
} }
if (ShmemVariableCache->nextOid < checkPoint.nextOid) if (ShmemVariableCache->nextOid < checkPoint.nextOid)
{ {
@ -2915,13 +2879,6 @@ xlog_desc(char *buf, uint8 xl_info, char* rec)
checkpoint->nextOid, checkpoint->nextOid,
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online"); (info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
} }
else if (info == XLOG_NEXTXID)
{
TransactionId nextXid;
memcpy(&nextXid, rec, sizeof(TransactionId));
sprintf(buf + strlen(buf), "nextXid: %u", nextXid);
}
else if (info == XLOG_NEXTOID) else if (info == XLOG_NEXTOID)
{ {
Oid nextOid; Oid nextOid;

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.26 2001/02/26 00:50:07 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.27 2001/03/18 20:18:59 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -296,7 +296,7 @@ GetSnapshotData(bool serializable)
/* /*
* Unfortunately, we have to call ReadNewTransactionId() after * Unfortunately, we have to call ReadNewTransactionId() after
* acquiring SInvalLock above. It's not good because * acquiring SInvalLock above. It's not good because
* ReadNewTransactionId() does SpinAcquire(OidGenLockId) but * ReadNewTransactionId() does SpinAcquire(XidGenLockId) but
* _necessary_. * _necessary_.
*/ */
ReadNewTransactionId(&(snapshot->xmax)); ReadNewTransactionId(&(snapshot->xmax));

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: transam.h,v 1.30 2001/03/13 01:17:06 tgl Exp $ * $Id: transam.h,v 1.31 2001/03/18 20:18:59 tgl Exp $
* *
* NOTES * NOTES
* Transaction System Version 101 now support proper oid * Transaction System Version 101 now support proper oid
@ -129,9 +129,8 @@ typedef VariableRelationContentsData *VariableRelationContents;
typedef struct VariableCacheData typedef struct VariableCacheData
{ {
TransactionId nextXid; /* next XID to assign */ TransactionId nextXid; /* next XID to assign */
uint32 xidCount; /* XIDs available before must do XLOG work */ Oid nextOid; /* next OID to assign */
Oid nextOid; /* and similarly for OIDs */ uint32 oidCount; /* OIDs available before must do XLOG work */
uint32 oidCount;
} VariableCacheData; } VariableCacheData;
typedef VariableCacheData *VariableCache; typedef VariableCacheData *VariableCache;

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: xlog.h,v 1.21 2001/03/16 05:44:33 tgl Exp $ * $Id: xlog.h,v 1.22 2001/03/18 20:18:59 tgl Exp $
*/ */
#ifndef XLOG_H #ifndef XLOG_H
#define XLOG_H #define XLOG_H
@ -201,7 +201,6 @@ extern void StartupXLOG(void);
extern void ShutdownXLOG(void); extern void ShutdownXLOG(void);
extern void CreateCheckPoint(bool shutdown); extern void CreateCheckPoint(bool shutdown);
extern void SetThisStartUpID(void); extern void SetThisStartUpID(void);
extern void XLogPutNextXid(TransactionId nextXid);
extern void XLogPutNextOid(Oid nextOid); extern void XLogPutNextOid(Oid nextOid);
extern void SetRedoRecPtr(void); extern void SetRedoRecPtr(void);
extern void GetRedoRecPtr(void); extern void GetRedoRecPtr(void);

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_control.h,v 1.1 2001/03/13 01:17:06 tgl Exp $ * $Id: pg_control.h,v 1.2 2001/03/18 20:18:59 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -45,7 +45,6 @@ typedef struct CheckPoint
/* XLOG info values for XLOG rmgr */ /* XLOG info values for XLOG rmgr */
#define XLOG_CHECKPOINT_SHUTDOWN 0x00 #define XLOG_CHECKPOINT_SHUTDOWN 0x00
#define XLOG_CHECKPOINT_ONLINE 0x10 #define XLOG_CHECKPOINT_ONLINE 0x10
#define XLOG_NEXTXID 0x20
#define XLOG_NEXTOID 0x30 #define XLOG_NEXTOID 0x30