Fix incomplete backpatch of pg_multixact truncation changes to <= 9.2
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Mon, 2 Dec 2013 16:28:10 +0000 (13:28 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Mon, 2 Dec 2013 16:28:10 +0000 (13:28 -0300)
The backpatch of a95335b544d9c8377e9dc7a399d8e9a155895f82 to 9.2, 9.1
and 9.0 was incomplete, missing changes to xlog.c, primarily the call
to TrimMultiXact(). Testing presumably didn't show a problem without
these changes because TrimMultiXact() performs defense-in-depth work,
which is not strictly necessary.

It also missed moving StartupMultiXact() which would have been
problematic if a restartpoing happened in exactly the wrong moment,
causing a transient error.

Andres Freund

src/backend/access/transam/xlog.c
src/include/access/multixact.h

index 47ecdac5fee18d76f25bd4a3c8ef4d1f270faa5d..c69130a3c5d32e58b07fa9ad20544d9aab870fc3 100644 (file)
@@ -5991,6 +5991,12 @@ StartupXLOG(void)
        XLogCtl->ckptXidEpoch = checkPoint.nextXidEpoch;
        XLogCtl->ckptXid = checkPoint.nextXid;
 
+       /*
+        * Startup MultiXact.  We need to do this early because we need its state
+        * initialized because we attempt truncation during restartpoints.
+        */
+       StartupMultiXact();
+
        /*
         * We must replay WAL entries using the same TimeLineID they were created
         * under, so temporarily adopt the TLI indicated by the checkpoint (see
@@ -6121,8 +6127,9 @@ StartupXLOG(void)
                        ProcArrayInitRecovery(ShmemVariableCache->nextXid);
 
                        /*
-                        * Startup commit log and subtrans only. Other SLRUs are not
-                        * maintained during recovery and need not be started yet.
+                        * Startup commit log and subtrans only. MultiXact has already
+                        * been started up and other SLRUs are not maintained during
+                        * recovery and need not be started yet.
                         */
                        StartupCLOG();
                        StartupSUBTRANS(oldestActiveXID);
@@ -6593,7 +6600,7 @@ StartupXLOG(void)
        /*
         * Perform end of recovery actions for any SLRUs that need it.
         */
-       StartupMultiXact();
+       TrimMultiXact();
        TrimCLOG();
 
        /* Reload shared-memory state for prepared transactions */
index c9a3a3d52db39b21e47bd7e162e30e88d138047f..3a21033f535ad96453439a720370eb904d97377f 100644 (file)
@@ -59,6 +59,7 @@ extern Size MultiXactShmemSize(void);
 extern void MultiXactShmemInit(void);
 extern void BootStrapMultiXact(void);
 extern void StartupMultiXact(void);
+extern void TrimMultiXact(void);
 extern void ShutdownMultiXact(void);
 extern void MultiXactGetCheckptMulti(bool is_shutdown,
                                                 MultiXactId *nextMulti,