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 d93e9ce27dc621e3ee7df78049a1afd20d42df35..3f73f9c733c324a89724742ea21bb60f97bbb0d5 100644 (file)
@@ -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 b85a619f77ebcf284d969bae760a9bbf0fdc2d40..a5f168cbf7f2f1f6910f4b883c7e0bc3979fb440 100644 (file)
@@ -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 5c24bc822d92bda006f16ddfa45607e41048cb93..2f7638fbb1cebdfec2e708b19e6ccf36c3fc227e 100644 (file)
@@ -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 c1de65a87720d5b9019a1e0f65994fe947b93c77..0ed745d105e3fc202c36af76e84f46b83ce76701 100644 (file)
@@ -775,7 +775,7 @@ ProcessUtility(Node *parsetree,
                        {
                                if (!superuser())
                                        elog(ERROR, "permission denied");
-                               CreateCheckPoint(false);
+                               CreateCheckPoint(false, false);
                        }
                        break;
 
index 9172d53569898b62e0591a994687182d252f1608..b7ba6ae7a69cbc094dd6561e1a533cdac356951c 100644 (file)
@@ -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);