Re: What is CheckPoint.undo needed for?

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Heikki Linnakangas <heikki(at)enterprisedb(dot)com>, Teodor Sigaev <teodor(at)sigaev(dot)ru>, Postgresql-General <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: What is CheckPoint.undo needed for?
Date: 2007-03-03 20:02:27
Message-ID: 200703032002.l23K2Rs20011@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Patch applied. Thanks.

---------------------------------------------------------------------------

Florian G. Pflug wrote:
> Tom Lane wrote:
> > Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> >> I think you should increase pg_control version.
> >
> > And the WAL page-header version, since this also changes WAL contents.
>
> Here is an updated version. I've incremeted XLOG_PAGE_MAGIC and
> PG_CONTROL_VERSION by one.
>
> greetings, Florian Pflug
>

> Index: src/backend/access/transam/xlog.c
> ===================================================================
> RCS file: /projects/cvsroot/pgsql/src/backend/access/transam/xlog.c,v
> retrieving revision 1.264
> diff -a -u -r1.264 xlog.c
> --- src/backend/access/transam/xlog.c 14 Feb 2007 05:00:40 -0000 1.264
> +++ src/backend/access/transam/xlog.c 23 Feb 2007 15:09:09 -0000
> @@ -4039,7 +4039,6 @@
> /* Set up information for the initial checkpoint record */
> checkPoint.redo.xlogid = 0;
> checkPoint.redo.xrecoff = SizeOfXLogLongPHD;
> - checkPoint.undo = checkPoint.redo;
> checkPoint.ThisTimeLineID = ThisTimeLineID;
> checkPoint.nextXidEpoch = 0;
> checkPoint.nextXid = FirstNormalTransactionId;
> @@ -4698,9 +4697,8 @@
> wasShutdown = (record->xl_info == XLOG_CHECKPOINT_SHUTDOWN);
>
> ereport(LOG,
> - (errmsg("redo record is at %X/%X; undo record is at %X/%X; shutdown %s",
> + (errmsg("redo record is at %X/%X; shutdown %s",
> checkPoint.redo.xlogid, checkPoint.redo.xrecoff,
> - checkPoint.undo.xlogid, checkPoint.undo.xrecoff,
> wasShutdown ? "TRUE" : "FALSE")));
> ereport(LOG,
> (errmsg("next transaction ID: %u/%u; next OID: %u",
> @@ -4730,20 +4728,17 @@
> if (XLByteLT(RecPtr, checkPoint.redo))
> ereport(PANIC,
> (errmsg("invalid redo in checkpoint record")));
> - if (checkPoint.undo.xrecoff == 0)
> - checkPoint.undo = RecPtr;
>
> /*
> * Check whether we need to force recovery from WAL. If it appears to
> * have been a clean shutdown and we did not have a recovery.conf file,
> * then assume no recovery needed.
> */
> - if (XLByteLT(checkPoint.undo, RecPtr) ||
> - XLByteLT(checkPoint.redo, RecPtr))
> + if (XLByteLT(checkPoint.redo, RecPtr))
> {
> if (wasShutdown)
> ereport(PANIC,
> - (errmsg("invalid redo/undo record in shutdown checkpoint")));
> + (errmsg("invalid redo record in shutdown checkpoint")));
> InRecovery = true;
> }
> else if (ControlFile->state != DB_SHUTDOWNED)
> @@ -5850,10 +5845,9 @@
> {
> CheckPoint *checkpoint = (CheckPoint *) rec;
>
> - appendStringInfo(buf, "checkpoint: redo %X/%X; undo %X/%X; "
> + appendStringInfo(buf, "checkpoint: redo %X/%X; "
> "tli %u; xid %u/%u; oid %u; multi %u; offset %u; %s",
> checkpoint->redo.xlogid, checkpoint->redo.xrecoff,
> - checkpoint->undo.xlogid, checkpoint->undo.xrecoff,
> checkpoint->ThisTimeLineID,
> checkpoint->nextXidEpoch, checkpoint->nextXid,
> checkpoint->nextOid,
> Index: src/bin/pg_controldata/pg_controldata.c
> ===================================================================
> RCS file: /projects/cvsroot/pgsql/src/bin/pg_controldata/pg_controldata.c,v
> retrieving revision 1.32
> diff -a -u -r1.32 pg_controldata.c
> --- src/bin/pg_controldata/pg_controldata.c 8 Dec 2006 19:50:53 -0000 1.32
> +++ src/bin/pg_controldata/pg_controldata.c 23 Feb 2007 15:09:09 -0000
> @@ -168,9 +168,6 @@
> printf(_("Latest checkpoint's REDO location: %X/%X\n"),
> ControlFile.checkPointCopy.redo.xlogid,
> ControlFile.checkPointCopy.redo.xrecoff);
> - printf(_("Latest checkpoint's UNDO location: %X/%X\n"),
> - ControlFile.checkPointCopy.undo.xlogid,
> - ControlFile.checkPointCopy.undo.xrecoff);
> printf(_("Latest checkpoint's TimeLineID: %u\n"),
> ControlFile.checkPointCopy.ThisTimeLineID);
> printf(_("Latest checkpoint's NextXID: %u/%u\n"),
> Index: src/bin/pg_resetxlog/pg_resetxlog.c
> ===================================================================
> RCS file: /projects/cvsroot/pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v
> retrieving revision 1.57
> diff -a -u -r1.57 pg_resetxlog.c
> --- src/bin/pg_resetxlog/pg_resetxlog.c 10 Feb 2007 14:58:55 -0000 1.57
> +++ src/bin/pg_resetxlog/pg_resetxlog.c 23 Feb 2007 15:09:09 -0000
> @@ -464,7 +464,6 @@
>
> ControlFile.checkPointCopy.redo.xlogid = 0;
> ControlFile.checkPointCopy.redo.xrecoff = SizeOfXLogLongPHD;
> - ControlFile.checkPointCopy.undo = ControlFile.checkPointCopy.redo;
> ControlFile.checkPointCopy.ThisTimeLineID = 1;
> ControlFile.checkPointCopy.nextXidEpoch = 0;
> ControlFile.checkPointCopy.nextXid = (TransactionId) 514; /* XXX */
> @@ -600,7 +599,6 @@
> ControlFile.checkPointCopy.redo.xlogid = newXlogId;
> ControlFile.checkPointCopy.redo.xrecoff =
> newXlogSeg * XLogSegSize + SizeOfXLogLongPHD;
> - ControlFile.checkPointCopy.undo = ControlFile.checkPointCopy.redo;
> ControlFile.checkPointCopy.time = time(NULL);
>
> ControlFile.state = DB_SHUTDOWNED;
> Index: src/include/access/xlog_internal.h
> ===================================================================
> RCS file: /projects/cvsroot/pgsql/src/include/access/xlog_internal.h,v
> retrieving revision 1.18
> diff -a -u -r1.18 xlog_internal.h
> --- src/include/access/xlog_internal.h 5 Jan 2007 22:19:51 -0000 1.18
> +++ src/include/access/xlog_internal.h 23 Feb 2007 15:09:09 -0000
> @@ -71,7 +71,7 @@
> /*
> * Each page of XLOG file has a header like this:
> */
> -#define XLOG_PAGE_MAGIC 0xD05E /* can be used as WAL version indicator */
> +#define XLOG_PAGE_MAGIC 0xD05F /* can be used as WAL version indicator */
>
> typedef struct XLogPageHeaderData
> {
> Index: src/include/catalog/pg_control.h
> ===================================================================
> RCS file: /projects/cvsroot/pgsql/src/include/catalog/pg_control.h,v
> retrieving revision 1.35
> diff -a -u -r1.35 pg_control.h
> --- src/include/catalog/pg_control.h 5 Jan 2007 22:19:52 -0000 1.35
> +++ src/include/catalog/pg_control.h 23 Feb 2007 15:09:09 -0000
> @@ -22,7 +22,7 @@
>
>
> /* Version identifier for this pg_control format */
> -#define PG_CONTROL_VERSION 831
> +#define PG_CONTROL_VERSION 832
>
> /*
> * Body of CheckPoint XLOG records. This is declared here because we keep
> @@ -32,9 +32,6 @@
> {
> XLogRecPtr redo; /* next RecPtr available when we began to
> * create CheckPoint (i.e. REDO start point) */
> - XLogRecPtr undo; /* first record of oldest in-progress
> - * transaction when we started (i.e. UNDO end
> - * point) */
> TimeLineID ThisTimeLineID; /* current TLI */
> uint32 nextXidEpoch; /* higher-order bits of nextXid */
> TransactionId nextXid; /* next free XID */
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2007-03-03 20:03:44 Re: What is CheckPoint.undo needed for?
Previous Message Martijn van Oosterhout 2007-03-03 19:46:14 Re: New Access Method