Skip to content

Commit 2e6107c

Browse files
committed
When archiving is enabled, rotate the last WAL segment at shutdown so that
all transactions are archived. Original patch by Guillaume Smet.
1 parent ee3980e commit 2e6107c

File tree

1 file changed

+12
-1
lines changed
  • src/backend/access/transam

1 file changed

+12
-1
lines changed

src/backend/access/transam/xlog.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.340 2009/05/15 15:56:39 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.341 2009/05/28 11:02:16 heikki Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -6085,7 +6085,18 @@ ShutdownXLOG(int code, Datum arg)
60856085
if (RecoveryInProgress())
60866086
CreateRestartPoint(CHECKPOINT_IS_SHUTDOWN | CHECKPOINT_IMMEDIATE);
60876087
else
6088+
{
6089+
/*
6090+
* If archiving is enabled, rotate the last XLOG file so that all the
6091+
* remaining records are archived (postmaster wakes up the archiver
6092+
* process one more time at the end of shutdown). The checkpoint
6093+
* record will go to the next XLOG file and won't be archived (yet).
6094+
*/
6095+
if (XLogArchivingActive() && XLogArchiveCommandSet())
6096+
RequestXLogSwitch();
6097+
60886098
CreateCheckPoint(CHECKPOINT_IS_SHUTDOWN | CHECKPOINT_IMMEDIATE);
6099+
}
60896100
ShutdownCLOG();
60906101
ShutdownSUBTRANS();
60916102
ShutdownMultiXact();

0 commit comments

Comments
 (0)