CreateRestartPoint(CHECKPOINT_IS_SHUTDOWN | CHECKPOINT_IMMEDIATE);
else
{
- /*
- * Take a snapshot of running transactions and write this to WAL.
- * This allows us to reconstruct the state of running transactions
- * during archive recovery, if required.
- */
- if (XLogArchivingActive() && XLogArchiveCommandSet())
- GetRunningTransactionData();
-
/*
* If archiving is enabled, rotate the last XLOG file so that all the
* remaining records are archived (postmaster wakes up the archiver
RequestXLogSwitch();
CreateCheckPoint(CHECKPOINT_IS_SHUTDOWN | CHECKPOINT_IMMEDIATE);
-
- /*
- * Take a snapshot of running transactions and write this to WAL.
- * This allows us to reconstruct the state of running transactions
- * during archive recovery, if required. We do this even if we are
- * not archiving, to allow a cold physical backup of the server to
- * be useful as a read only standby.
- */
- GetRunningTransactionData();
}
ShutdownCLOG();
ShutdownSUBTRANS();
*/
LWLockRelease(WALInsertLock);
+ /*
+ * Take a snapshot of running transactions and write this to WAL.
+ * This allows us to reconstruct the state of running transactions
+ * during archive recovery, if required. We do this even if we are
+ * not archiving, to allow a cold physical backup of the server to
+ * be useful as a read only standby.
+ */
+ if (shutdown || (XLogArchivingActive() && XLogArchiveCommandSet()))
+ {
+ /*
+ * GetRunningTransactionData() inserts WAL records while holding
+ * ProcArrayLock. Make sure we flush WAL first so we reduce the
+ * chance of needing to flush WAL during XLogInsert(), which might
+ * mean we hold ProcArrayLock across an I/O, which could be bad.
+ */
+ if (!shutdown)
+ XLogBackgroundFlush();
+ GetRunningTransactionData();
+ }
+
/*
* If enabled, log checkpoint start. We postpone this until now so as not
* to log anything if we decided to skip the checkpoint.
CheckpointStats.ckpt_segs_recycled);
LWLockRelease(CheckpointLock);
-
- /*
- * Take a snapshot of running transactions and write this to WAL.
- * This allows us to reconstruct the state of running transactions
- * during archive recovery, if required. If we aren't archiving,
- * don't bother.
- *
- * If we are shutting down, or Startup process is completing crash
- * recovery we don't need to write running xact data.
- */
- if (!shutdown && XLogArchivingActive() && !RecoveryInProgress())
- {
- /*
- * GetRunningTransactionData() inserts WAL records while holding
- * ProcArrayLock. Make sure we flush WAL first so we reduce the
- * chance of needing to flush WAL during XLogInsert(), which might
- * mean we hold ProcArrayLock across an I/O, which could be bad.
- */
- XLogBackgroundFlush();
- GetRunningTransactionData();
- }
}
/*