From: Heikki Linnakangas Date: Thu, 28 May 2009 11:02:16 +0000 (+0000) Subject: When archiving is enabled, rotate the last WAL segment at shutdown so that X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=2338ed5e493d2063418f133dc712f88de94daa95;p=users%2Fsimon%2Fpostgres.git When archiving is enabled, rotate the last WAL segment at shutdown so that all transactions are archived. Original patch by Guillaume Smet. --- diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 1b575e242a..64e8ead74c 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -6085,7 +6085,18 @@ ShutdownXLOG(int code, Datum arg) if (RecoveryInProgress()) CreateRestartPoint(CHECKPOINT_IS_SHUTDOWN | CHECKPOINT_IMMEDIATE); else + { + /* + * If archiving is enabled, rotate the last XLOG file so that all the + * remaining records are archived (postmaster wakes up the archiver + * process one more time at the end of shutdown). The checkpoint + * record will go to the next XLOG file and won't be archived (yet). + */ + if (XLogArchivingActive() && XLogArchiveCommandSet()) + RequestXLogSwitch(); + CreateCheckPoint(CHECKPOINT_IS_SHUTDOWN | CHECKPOINT_IMMEDIATE); + } ShutdownCLOG(); ShutdownSUBTRANS(); ShutdownMultiXact();