Ensure that before truncating CLOG, we force a checkpoint even if no
recent WAL activity has occurred. Without this, it's possible that a later crash might leave tuples on disk with un-updated commit status bits.
This commit is contained in:
parent
c87469e64a
commit
b2ab1e6bc9
@ -13,7 +13,7 @@
|
|||||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2002, 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/clog.c,v 1.10 2002/09/02 02:47:01 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/transam/clog.c,v 1.11 2002/09/26 22:58:33 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -809,8 +809,8 @@ TruncateCLOG(TransactionId oldestXact)
|
|||||||
if (!ScanCLOGDirectory(cutoffPage, false))
|
if (!ScanCLOGDirectory(cutoffPage, false))
|
||||||
return; /* nothing to remove */
|
return; /* nothing to remove */
|
||||||
|
|
||||||
/* Perform a CHECKPOINT */
|
/* Perform a forced CHECKPOINT */
|
||||||
CreateCheckPoint(false);
|
CreateCheckPoint(false, true);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Scan CLOG shared memory and remove any pages preceding the cutoff
|
* Scan CLOG shared memory and remove any pages preceding the cutoff
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2002, 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.106 2002/09/04 20:31:13 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.107 2002/09/26 22:58:33 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -2743,7 +2743,7 @@ StartupXLOG(void)
|
|||||||
* checkpoint to become prevCheckPoint...
|
* checkpoint to become prevCheckPoint...
|
||||||
*/
|
*/
|
||||||
ControlFile->checkPoint = checkPointLoc;
|
ControlFile->checkPoint = checkPointLoc;
|
||||||
CreateCheckPoint(true);
|
CreateCheckPoint(true, true);
|
||||||
XLogCloseRelationCache();
|
XLogCloseRelationCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2901,7 +2901,7 @@ ShutdownXLOG(void)
|
|||||||
|
|
||||||
CritSectionCount++;
|
CritSectionCount++;
|
||||||
CreateDummyCaches();
|
CreateDummyCaches();
|
||||||
CreateCheckPoint(true);
|
CreateCheckPoint(true, true);
|
||||||
ShutdownCLOG();
|
ShutdownCLOG();
|
||||||
CritSectionCount--;
|
CritSectionCount--;
|
||||||
|
|
||||||
@ -2910,9 +2910,12 @@ ShutdownXLOG(void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Perform a checkpoint --- either during shutdown, or on-the-fly
|
* Perform a checkpoint --- either during shutdown, or on-the-fly
|
||||||
|
*
|
||||||
|
* If force is true, we force a checkpoint regardless of whether any XLOG
|
||||||
|
* activity has occurred since the last one.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
CreateCheckPoint(bool shutdown)
|
CreateCheckPoint(bool shutdown, bool force)
|
||||||
{
|
{
|
||||||
CheckPoint checkPoint;
|
CheckPoint checkPoint;
|
||||||
XLogRecPtr recptr;
|
XLogRecPtr recptr;
|
||||||
@ -2955,21 +2958,21 @@ CreateCheckPoint(bool shutdown)
|
|||||||
LWLockAcquire(WALInsertLock, LW_EXCLUSIVE);
|
LWLockAcquire(WALInsertLock, LW_EXCLUSIVE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this isn't a shutdown, and we have not inserted any XLOG records
|
* If this isn't a shutdown or forced checkpoint, and we have not inserted
|
||||||
* since the start of the last checkpoint, skip the checkpoint. The
|
* any XLOG records since the start of the last checkpoint, skip the
|
||||||
* idea here is to avoid inserting duplicate checkpoints when the
|
* checkpoint. The idea here is to avoid inserting duplicate checkpoints
|
||||||
* system is idle. That wastes log space, and more importantly it
|
* when the system is idle. That wastes log space, and more importantly it
|
||||||
* exposes us to possible loss of both current and previous checkpoint
|
* exposes us to possible loss of both current and previous checkpoint
|
||||||
* records if the machine crashes just as we're writing the update.
|
* records if the machine crashes just as we're writing the update.
|
||||||
* (Perhaps it'd make even more sense to checkpoint only when the
|
* (Perhaps it'd make even more sense to checkpoint only when the previous
|
||||||
* previous checkpoint record is in a different xlog page?)
|
* checkpoint record is in a different xlog page?)
|
||||||
*
|
*
|
||||||
* We have to make two tests to determine that nothing has happened since
|
* We have to make two tests to determine that nothing has happened since
|
||||||
* the start of the last checkpoint: current insertion point must
|
* the start of the last checkpoint: current insertion point must
|
||||||
* match the end of the last checkpoint record, and its redo pointer
|
* match the end of the last checkpoint record, and its redo pointer
|
||||||
* must point to itself.
|
* must point to itself.
|
||||||
*/
|
*/
|
||||||
if (!shutdown)
|
if (!shutdown && !force)
|
||||||
{
|
{
|
||||||
XLogRecPtr curInsert;
|
XLogRecPtr curInsert;
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.143 2002/09/25 20:31:40 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.144 2002/09/26 22:58:33 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -390,7 +390,7 @@ BootstrapMain(int argc, char *argv[])
|
|||||||
|
|
||||||
case BS_XLOG_CHECKPOINT:
|
case BS_XLOG_CHECKPOINT:
|
||||||
CreateDummyCaches();
|
CreateDummyCaches();
|
||||||
CreateCheckPoint(false);
|
CreateCheckPoint(false, false);
|
||||||
SetSavedRedoRecPtr(); /* pass redo ptr back to
|
SetSavedRedoRecPtr(); /* pass redo ptr back to
|
||||||
* postmaster */
|
* postmaster */
|
||||||
proc_exit(0); /* done */
|
proc_exit(0); /* done */
|
||||||
@ -445,7 +445,7 @@ BootstrapMain(int argc, char *argv[])
|
|||||||
Int_yyparse();
|
Int_yyparse();
|
||||||
|
|
||||||
SetProcessingMode(NormalProcessing);
|
SetProcessingMode(NormalProcessing);
|
||||||
CreateCheckPoint(true);
|
CreateCheckPoint(true, true);
|
||||||
SetProcessingMode(BootstrapProcessing);
|
SetProcessingMode(BootstrapProcessing);
|
||||||
|
|
||||||
/* clean up processing */
|
/* clean up processing */
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.177 2002/09/04 20:31:26 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.178 2002/09/26 22:58:33 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -831,11 +831,9 @@ ProcessUtility(Node *parsetree,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case T_CheckPointStmt:
|
case T_CheckPointStmt:
|
||||||
{
|
if (!superuser())
|
||||||
if (!superuser())
|
elog(ERROR, "permission denied");
|
||||||
elog(ERROR, "permission denied");
|
CreateCheckPoint(false, false);
|
||||||
CreateCheckPoint(false);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_ReindexStmt:
|
case T_ReindexStmt:
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2002, 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.38 2002/09/26 22:46:29 tgl Exp $
|
* $Id: xlog.h,v 1.39 2002/09/26 22:58:34 tgl Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef XLOG_H
|
#ifndef XLOG_H
|
||||||
#define XLOG_H
|
#define XLOG_H
|
||||||
@ -204,7 +204,7 @@ extern void XLOGPathInit(void);
|
|||||||
extern void BootStrapXLOG(void);
|
extern void BootStrapXLOG(void);
|
||||||
extern void StartupXLOG(void);
|
extern void StartupXLOG(void);
|
||||||
extern void ShutdownXLOG(void);
|
extern void ShutdownXLOG(void);
|
||||||
extern void CreateCheckPoint(bool shutdown);
|
extern void CreateCheckPoint(bool shutdown, bool force);
|
||||||
extern void SetThisStartUpID(void);
|
extern void SetThisStartUpID(void);
|
||||||
extern void XLogPutNextOid(Oid nextOid);
|
extern void XLogPutNextOid(Oid nextOid);
|
||||||
extern void SetSavedRedoRecPtr(void);
|
extern void SetSavedRedoRecPtr(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user