Back-patch fix to ensure a checkpoint occurs before truncating CLOG,
authorTom Lane <[email protected]>
Mon, 30 Sep 2002 19:55:08 +0000 (19:55 +0000)
committerTom Lane <[email protected]>
Mon, 30 Sep 2002 19:55:08 +0000 (19:55 +0000)
even if no recent WAL activity has occurred.

src/backend/access/transam/clog.c
src/backend/access/transam/xlog.c
src/backend/bootstrap/bootstrap.c
src/backend/tcop/utility.c
src/include/access/xlog.h

index 7f38b47d767a871960843ab911e671431860b6d8..fb7552d229e2770cb0b0c0b1c099bc0790a0556c 100644 (file)
@@ -13,7 +13,7 @@
  * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Header: /cvsroot/pgsql/src/backend/access/transam/clog.c,v 1.7 2001/10/28 06:25:42 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/clog.c,v 1.7.2.1 2002/09/30 19:55:08 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -810,8 +810,8 @@ TruncateCLOG(TransactionId oldestXact)
    if (!ScanCLOGDirectory(cutoffPage, false))
        return;                 /* nothing to remove */
 
-   /* Perform a CHECKPOINT */
-   CreateCheckPoint(false);
+   /* Perform a forced CHECKPOINT */
+   CreateCheckPoint(false, true);
 
    /*
     * Scan CLOG shared memory and remove any pages preceding the cutoff
index a964a339f1f7368b567787f111bf2590c90480b7..77e1f0a93691f28b6077e8ab9fb5036d5b4bf18d 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.86.2.1 2002/03/15 19:20:43 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.86.2.2 2002/09/30 19:55:08 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -2737,7 +2737,7 @@ StartupXLOG(void)
         * checkpoint to become prevCheckPoint...
         */
        ControlFile->checkPoint = checkPointLoc;
-       CreateCheckPoint(true);
+       CreateCheckPoint(true, true);
        XLogCloseRelationCache();
    }
 
@@ -2894,7 +2894,7 @@ ShutdownXLOG(void)
 
    CritSectionCount++;
    CreateDummyCaches();
-   CreateCheckPoint(true);
+   CreateCheckPoint(true, true);
    ShutdownCLOG();
    CritSectionCount--;
 
@@ -2905,7 +2905,7 @@ ShutdownXLOG(void)
  * Perform a checkpoint --- either during shutdown, or on-the-fly
  */
 void
-CreateCheckPoint(bool shutdown)
+CreateCheckPoint(bool shutdown, bool force)
 {
    CheckPoint  checkPoint;
    XLogRecPtr  recptr;
@@ -2962,7 +2962,7 @@ CreateCheckPoint(bool shutdown)
     * match the end of the last checkpoint record, and its redo pointer
     * must point to itself.
     */
-   if (!shutdown)
+   if (!shutdown && !force)
    {
        XLogRecPtr  curInsert;
 
index 44d5e2efd98c6a12db5f68d28f4a62357b089635..f3b6f1f9558b09df3491787e80d37f5ba2661e0a 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.120.2.1 2002/03/15 19:20:44 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.120.2.2 2002/09/30 19:55:08 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -379,7 +379,7 @@ BootstrapMain(int argc, char *argv[])
            if (IsUnderPostmaster)
                InitDummyProcess();     /* needed to get LWLocks */
            CreateDummyCaches();
-           CreateCheckPoint(false);
+           CreateCheckPoint(false, false);
            SetSavedRedoRecPtr(); /* pass redo ptr back to postmaster */
            proc_exit(0);       /* done */
 
@@ -433,7 +433,7 @@ BootstrapMain(int argc, char *argv[])
    Int_yyparse();
 
    SetProcessingMode(NormalProcessing);
-   CreateCheckPoint(true);
+   CreateCheckPoint(true, true);
    SetProcessingMode(BootstrapProcessing);
 
    /* clean up processing */
index 41fd1674da6aae9d4f92a12130bb9004c2c76c30..c0d2362f7676ebc178f9e942dfe92b4380ee3fcb 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.125.2.1 2002/02/26 23:48:46 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.125.2.2 2002/09/30 19:55:08 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -775,7 +775,7 @@ ProcessUtility(Node *parsetree,
            {
                if (!superuser())
                    elog(ERROR, "permission denied");
-               CreateCheckPoint(false);
+               CreateCheckPoint(false, false);
            }
            break;
 
index e87d06d50857f5097a7e1ab10d83262e062f1f9b..4ed5e87147b1f01f3c08527942f1899be9d60bb6 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: xlog.h,v 1.28.2.1 2002/03/15 19:20:47 tgl Exp $
+ * $Id: xlog.h,v 1.28.2.2 2002/09/30 19:55:08 tgl Exp $
  */
 #ifndef XLOG_H
 #define XLOG_H
@@ -204,7 +204,7 @@ extern void XLOGPathInit(void);
 extern void BootStrapXLOG(void);
 extern void StartupXLOG(void);
 extern void ShutdownXLOG(void);
-extern void CreateCheckPoint(bool shutdown);
+extern void CreateCheckPoint(bool shutdown, bool force);
 extern void SetThisStartUpID(void);
 extern void XLogPutNextOid(Oid nextOid);
 extern void SetSavedRedoRecPtr(void);