diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2009-05-28 11:02:16 +0000 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2009-05-28 11:02:16 +0000 |
commit | 2e6107cb621d003dcab0df53ac8673ea67c4e467 (patch) | |
tree | 5026e67158b051321d5695ea128feff10f96c417 | |
parent | ee3980ebf3713bd977385d4250eab6231f53cc8f (diff) | |
download | postgresql-2e6107cb621d003dcab0df53ac8673ea67c4e467.tar.gz postgresql-2e6107cb621d003dcab0df53ac8673ea67c4e467.zip |
When archiving is enabled, rotate the last WAL segment at shutdown so that
all transactions are archived.
Original patch by Guillaume Smet.
-rw-r--r-- | src/backend/access/transam/xlog.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 93f00c9f6c0..ecf5046ff9a 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.340 2009/05/15 15:56:39 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.341 2009/05/28 11:02:16 heikki Exp $ * *------------------------------------------------------------------------- */ @@ -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(); |