Skip to content

Commit 7d4d5c0

Browse files
committed
Arrange to recycle old XLOG log segment files as new segment files,
rather than deleting them only to have to create more. Steady state is 2*CHECKPOINT_SEGMENTS + WAL_FILES + 1 segment files, which will simply be renamed rather than constantly deleted and recreated. To make this safe, added current XLOG file/offset number to page header of XLOG pages, so that an un-overwritten page from an old incarnation of a logfile can be reliably told from a valid page. This change means that if you try to restart postmaster in a CVS-tip database after installing the change, you'll get a complaint about bad XLOG page magic number. If you don't want to initdb, run contrib/pg_resetxlog (and be sure you shut down the old postmaster cleanly).
1 parent 8b77efd commit 7d4d5c0

File tree

3 files changed

+198
-73
lines changed

3 files changed

+198
-73
lines changed

contrib/pg_resetxlog/pg_resetxlog.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
2424
* Portions Copyright (c) 1994, Regents of the University of California
2525
*
26-
* $Header: /cvsroot/pgsql/contrib/pg_resetxlog/Attic/pg_resetxlog.c,v 1.5 2001/06/06 17:07:38 tgl Exp $
26+
* $Header: /cvsroot/pgsql/contrib/pg_resetxlog/Attic/pg_resetxlog.c,v 1.6 2001/07/19 02:12:34 tgl Exp $
2727
*
2828
*-------------------------------------------------------------------------
2929
*/
@@ -857,6 +857,10 @@ WriteEmptyXLOG(void)
857857
page->xlp_magic = XLOG_PAGE_MAGIC;
858858
page->xlp_info = 0;
859859
page->xlp_sui = ControlFile.checkPointCopy.ThisStartUpID;
860+
page->xlp_pageaddr.xlogid =
861+
ControlFile.checkPointCopy.redo.xlogid;
862+
page->xlp_pageaddr.xrecoff =
863+
ControlFile.checkPointCopy.redo.xrecoff - SizeOfXLogPHD;
860864
record = (XLogRecord *) ((char *) page + SizeOfXLogPHD);
861865
record->xl_prev.xlogid = 0;
862866
record->xl_prev.xrecoff = 0;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy