@@ -8076,6 +8076,42 @@ CreateCheckPoint(int flags)
80768076
80778077TRACE_POSTGRESQL_CHECKPOINT_START (flags );
80788078
8079+ /*
8080+ * Get the other info we need for the checkpoint record.
8081+ */
8082+ LWLockAcquire (XidGenLock ,LW_SHARED );
8083+ checkPoint .nextXid = ShmemVariableCache -> nextXid ;
8084+ checkPoint .oldestXid = ShmemVariableCache -> oldestXid ;
8085+ checkPoint .oldestXidDB = ShmemVariableCache -> oldestXidDB ;
8086+ LWLockRelease (XidGenLock );
8087+
8088+ /* Increase XID epoch if we've wrapped around since last checkpoint */
8089+ checkPoint .nextXidEpoch = ControlFile -> checkPointCopy .nextXidEpoch ;
8090+ if (checkPoint .nextXid < ControlFile -> checkPointCopy .nextXid )
8091+ checkPoint .nextXidEpoch ++ ;
8092+
8093+ LWLockAcquire (OidGenLock ,LW_SHARED );
8094+ checkPoint .nextOid = ShmemVariableCache -> nextOid ;
8095+ if (!shutdown )
8096+ checkPoint .nextOid += ShmemVariableCache -> oidCount ;
8097+ LWLockRelease (OidGenLock );
8098+
8099+ MultiXactGetCheckptMulti (shutdown ,
8100+ & checkPoint .nextMulti ,
8101+ & checkPoint .nextMultiOffset ,
8102+ & checkPoint .oldestMulti ,
8103+ & checkPoint .oldestMultiDB );
8104+
8105+ /*
8106+ * Having constructed the checkpoint record, ensure all shmem disk buffers
8107+ * and commit-log buffers are flushed to disk.
8108+ *
8109+ * This I/O could fail for various reasons. If so, we will fail to
8110+ * complete the checkpoint, but there is no reason to force a system
8111+ * panic. Accordingly, exit critical section while doing it.
8112+ */
8113+ END_CRIT_SECTION ();
8114+
80798115/*
80808116 * In some cases there are groups of actions that must all occur on one
80818117 * side or the other of a checkpoint record. Before flushing the
@@ -8116,42 +8152,6 @@ CreateCheckPoint(int flags)
81168152}
81178153pfree (vxids );
81188154
8119- /*
8120- * Get the other info we need for the checkpoint record.
8121- */
8122- LWLockAcquire (XidGenLock ,LW_SHARED );
8123- checkPoint .nextXid = ShmemVariableCache -> nextXid ;
8124- checkPoint .oldestXid = ShmemVariableCache -> oldestXid ;
8125- checkPoint .oldestXidDB = ShmemVariableCache -> oldestXidDB ;
8126- LWLockRelease (XidGenLock );
8127-
8128- /* Increase XID epoch if we've wrapped around since last checkpoint */
8129- checkPoint .nextXidEpoch = ControlFile -> checkPointCopy .nextXidEpoch ;
8130- if (checkPoint .nextXid < ControlFile -> checkPointCopy .nextXid )
8131- checkPoint .nextXidEpoch ++ ;
8132-
8133- LWLockAcquire (OidGenLock ,LW_SHARED );
8134- checkPoint .nextOid = ShmemVariableCache -> nextOid ;
8135- if (!shutdown )
8136- checkPoint .nextOid += ShmemVariableCache -> oidCount ;
8137- LWLockRelease (OidGenLock );
8138-
8139- MultiXactGetCheckptMulti (shutdown ,
8140- & checkPoint .nextMulti ,
8141- & checkPoint .nextMultiOffset ,
8142- & checkPoint .oldestMulti ,
8143- & checkPoint .oldestMultiDB );
8144-
8145- /*
8146- * Having constructed the checkpoint record, ensure all shmem disk buffers
8147- * and commit-log buffers are flushed to disk.
8148- *
8149- * This I/O could fail for various reasons. If so, we will fail to
8150- * complete the checkpoint, but there is no reason to force a system
8151- * panic. Accordingly, exit critical section while doing it.
8152- */
8153- END_CRIT_SECTION ();
8154-
81558155CheckPointGuts (checkPoint .redo ,flags );
81568156
81578157/*