mirror of
https://github.com/postgres/postgres.git
synced 2025-08-09 17:03:00 +03:00
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).
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/contrib/pg_resetxlog/Attic/pg_resetxlog.c,v 1.5 2001/06/06 17:07:38 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/contrib/pg_resetxlog/Attic/pg_resetxlog.c,v 1.6 2001/07/19 02:12:34 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -857,6 +857,10 @@ WriteEmptyXLOG(void)
|
||||
page->xlp_magic = XLOG_PAGE_MAGIC;
|
||||
page->xlp_info = 0;
|
||||
page->xlp_sui = ControlFile.checkPointCopy.ThisStartUpID;
|
||||
page->xlp_pageaddr.xlogid =
|
||||
ControlFile.checkPointCopy.redo.xlogid;
|
||||
page->xlp_pageaddr.xrecoff =
|
||||
ControlFile.checkPointCopy.redo.xrecoff - SizeOfXLogPHD;
|
||||
record = (XLogRecord *) ((char *) page + SizeOfXLogPHD);
|
||||
record->xl_prev.xlogid = 0;
|
||||
record->xl_prev.xrecoff = 0;
|
||||
|
Reference in New Issue
Block a user