Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit af6e88a

Browse files
committed
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.
1 parent ddc5bc9 commit af6e88a

File tree

7 files changed

+12
-67
lines changed

7 files changed

+12
-67
lines changed

src/backend/access/transam/transam.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.40 2001/03/13 01:17:05 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.41 2001/03/18 20:18:59 tgl Exp $
1212
*
1313
* NOTES
1414
* This file contains the high level access-method interface to the
@@ -430,7 +430,6 @@ InitializeTransactionLog(void)
430430
Assert(!IsUnderPostmaster &&
431431
ShmemVariableCache->nextXid <= FirstTransactionId);
432432
ShmemVariableCache->nextXid = FirstTransactionId;
433-
ShmemVariableCache->xidCount = 0; /* force an XLOG rec right away */
434433
}
435434
else if (RecoveryCheckingEnabled())
436435
{

src/backend/access/transam/varsup.c

+1-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 2000, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.36 2001/03/13 01:17:05 tgl Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.37 2001/03/18 20:18:59 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -44,17 +44,9 @@ GetNewTransactionId(TransactionId *xid)
4444

4545
SpinAcquire(XidGenLockId);
4646

47-
/* If we run out of logged for use xids then we must log more */
48-
if (ShmemVariableCache->xidCount == 0)
49-
{
50-
XLogPutNextXid(ShmemVariableCache->nextXid + VAR_XID_PREFETCH);
51-
ShmemVariableCache->xidCount = VAR_XID_PREFETCH;
52-
}
53-
5447
*xid = ShmemVariableCache->nextXid;
5548

5649
(ShmemVariableCache->nextXid)++;
57-
(ShmemVariableCache->xidCount)--;
5850

5951
SpinRelease(XidGenLockId);
6052

src/backend/access/transam/xlog.c

+3-46
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.61 2001/03/18 00:30:27 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.62 2001/03/18 20:18:59 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -2161,7 +2161,6 @@ BootStrapXLOG(void)
21612161
checkPoint.time = time(NULL);
21622162

21632163
ShmemVariableCache->nextXid = checkPoint.nextXid;
2164-
ShmemVariableCache->xidCount = 0;
21652164
ShmemVariableCache->nextOid = checkPoint.nextOid;
21662165
ShmemVariableCache->oidCount = 0;
21672166

@@ -2317,7 +2316,6 @@ StartupXLOG(void)
23172316
elog(STOP, "Invalid NextTransactionId/NextOid");
23182317

23192318
ShmemVariableCache->nextXid = checkPoint.nextXid;
2320-
ShmemVariableCache->xidCount = 0;
23212319
ShmemVariableCache->nextOid = checkPoint.nextOid;
23222320
ShmemVariableCache->oidCount = 0;
23232321

@@ -2368,11 +2366,7 @@ StartupXLOG(void)
23682366
do
23692367
{
23702368
if (record->xl_xid >= ShmemVariableCache->nextXid)
2371-
{
2372-
/* This probably shouldn't happen... */
23732369
ShmemVariableCache->nextXid = record->xl_xid + 1;
2374-
ShmemVariableCache->xidCount = 0;
2375-
}
23762370
if (XLOG_DEBUG)
23772371
{
23782372
char buf[8192];
@@ -2717,8 +2711,6 @@ CreateCheckPoint(bool shutdown)
27172711

27182712
SpinAcquire(XidGenLockId);
27192713
checkPoint.nextXid = ShmemVariableCache->nextXid;
2720-
if (!shutdown)
2721-
checkPoint.nextXid += ShmemVariableCache->xidCount;
27222714
SpinRelease(XidGenLockId);
27232715

27242716
SpinAcquire(OidGenLockId);
@@ -2803,21 +2795,6 @@ CreateCheckPoint(bool shutdown)
28032795
END_CRIT_SECTION();
28042796
}
28052797

2806-
/*
2807-
* Write a NEXTXID log record
2808-
*/
2809-
void
2810-
XLogPutNextXid(TransactionId nextXid)
2811-
{
2812-
XLogRecData rdata;
2813-
2814-
rdata.buffer = InvalidBuffer;
2815-
rdata.data = (char *)(&nextXid);
2816-
rdata.len = sizeof(TransactionId);
2817-
rdata.next = NULL;
2818-
(void) XLogInsert(RM_XLOG_ID, XLOG_NEXTXID, &rdata);
2819-
}
2820-
28212798
/*
28222799
* Write a NEXTOID log record
28232800
*/
@@ -2841,18 +2818,7 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
28412818
{
28422819
uint8 info = record->xl_info & ~XLR_INFO_MASK;
28432820

2844-
if (info == XLOG_NEXTXID)
2845-
{
2846-
TransactionId nextXid;
2847-
2848-
memcpy(&nextXid, XLogRecGetData(record), sizeof(TransactionId));
2849-
if (ShmemVariableCache->nextXid < nextXid)
2850-
{
2851-
ShmemVariableCache->nextXid = nextXid;
2852-
ShmemVariableCache->xidCount = 0;
2853-
}
2854-
}
2855-
else if (info == XLOG_NEXTOID)
2821+
if (info == XLOG_NEXTOID)
28562822
{
28572823
Oid nextOid;
28582824

@@ -2870,7 +2836,6 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
28702836
memcpy(&checkPoint, XLogRecGetData(record), sizeof(CheckPoint));
28712837
/* In a SHUTDOWN checkpoint, believe the counters exactly */
28722838
ShmemVariableCache->nextXid = checkPoint.nextXid;
2873-
ShmemVariableCache->xidCount = 0;
28742839
ShmemVariableCache->nextOid = checkPoint.nextOid;
28752840
ShmemVariableCache->oidCount = 0;
28762841
}
@@ -2879,11 +2844,10 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
28792844
CheckPoint checkPoint;
28802845

28812846
memcpy(&checkPoint, XLogRecGetData(record), sizeof(CheckPoint));
2882-
/* In an ONLINE checkpoint, treat the counters like NEXTXID/NEXTOID */
2847+
/* In an ONLINE checkpoint, treat the counters like NEXTOID */
28832848
if (ShmemVariableCache->nextXid < checkPoint.nextXid)
28842849
{
28852850
ShmemVariableCache->nextXid = checkPoint.nextXid;
2886-
ShmemVariableCache->xidCount = 0;
28872851
}
28882852
if (ShmemVariableCache->nextOid < checkPoint.nextOid)
28892853
{
@@ -2915,13 +2879,6 @@ xlog_desc(char *buf, uint8 xl_info, char* rec)
29152879
checkpoint->nextOid,
29162880
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
29172881
}
2918-
else if (info == XLOG_NEXTXID)
2919-
{
2920-
TransactionId nextXid;
2921-
2922-
memcpy(&nextXid, rec, sizeof(TransactionId));
2923-
sprintf(buf + strlen(buf), "nextXid: %u", nextXid);
2924-
}
29252882
else if (info == XLOG_NEXTOID)
29262883
{
29272884
Oid nextOid;

src/backend/storage/ipc/sinval.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.26 2001/02/26 00:50:07 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.27 2001/03/18 20:18:59 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -296,7 +296,7 @@ GetSnapshotData(bool serializable)
296296
/*
297297
* Unfortunately, we have to call ReadNewTransactionId() after
298298
* acquiring SInvalLock above. It's not good because
299-
* ReadNewTransactionId() does SpinAcquire(OidGenLockId) but
299+
* ReadNewTransactionId() does SpinAcquire(XidGenLockId) but
300300
* _necessary_.
301301
*/
302302
ReadNewTransactionId(&(snapshot->xmax));

src/include/access/transam.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: transam.h,v 1.30 2001/03/13 01:17:06 tgl Exp $
10+
* $Id: transam.h,v 1.31 2001/03/18 20:18:59 tgl Exp $
1111
*
1212
* NOTES
1313
* Transaction System Version 101 now support proper oid
@@ -129,9 +129,8 @@ typedef VariableRelationContentsData *VariableRelationContents;
129129
typedef struct VariableCacheData
130130
{
131131
TransactionId nextXid; /* next XID to assign */
132-
uint32 xidCount; /* XIDs available before must do XLOG work */
133-
Oid nextOid; /* and similarly for OIDs */
134-
uint32 oidCount;
132+
Oid nextOid; /* next OID to assign */
133+
uint32 oidCount; /* OIDs available before must do XLOG work */
135134
} VariableCacheData;
136135

137136
typedef VariableCacheData *VariableCache;

src/include/access/xlog.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: xlog.h,v 1.21 2001/03/16 05:44:33 tgl Exp $
9+
* $Id: xlog.h,v 1.22 2001/03/18 20:18:59 tgl Exp $
1010
*/
1111
#ifndef XLOG_H
1212
#define XLOG_H
@@ -201,7 +201,6 @@ extern void StartupXLOG(void);
201201
extern void ShutdownXLOG(void);
202202
extern void CreateCheckPoint(bool shutdown);
203203
extern void SetThisStartUpID(void);
204-
extern void XLogPutNextXid(TransactionId nextXid);
205204
extern void XLogPutNextOid(Oid nextOid);
206205
extern void SetRedoRecPtr(void);
207206
extern void GetRedoRecPtr(void);

src/include/catalog/pg_control.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $Id: pg_control.h,v 1.1 2001/03/13 01:17:06 tgl Exp $
11+
* $Id: pg_control.h,v 1.2 2001/03/18 20:18:59 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -45,7 +45,6 @@ typedef struct CheckPoint
4545
/* XLOG info values for XLOG rmgr */
4646
#define XLOG_CHECKPOINT_SHUTDOWN 0x00
4747
#define XLOG_CHECKPOINT_ONLINE 0x10
48-
#define XLOG_NEXTXID 0x20
4948
#define XLOG_NEXTOID 0x30
5049

5150

0 commit comments

Comments
 (0)