Thread: What is CheckPoint.undo needed for?

What is CheckPoint.undo needed for?

From
"Florian G. Pflug"
Date:
Hi

I'm trying to gain a better understanding of how the postgres
xlog works - especially about the corner cases of wal replay.

One thing that I do not understand is what CheckPoint.undo is
used for. I grepped through the source, and only see very few
references to it, which either just print it, or set it to
the checkpoint location or the redo location.

The only place where is is checked is
if (XLByteLT(checkPoint.undo, RecPtr) || XLByteLT(checkPoint.redo, RecPtr))
but I don't see the reason for this check, given that undo never
seems to be assigned any interesting value..

Is there any in-depth documentation about the postgres xlog
implementation?
What am I missing?

greetings, Florian Pflug


Re: What is CheckPoint.undo needed for?

From
Teodor Sigaev
Date:
> What am I missing?
Seems, it's about that
http://archives.postgresql.org/pgsql-committers/2005-06/msg00085.php

-- 
Teodor Sigaev                                   E-mail: teodor@sigaev.ru
  WWW: http://www.sigaev.ru/
 


Re: What is CheckPoint.undo needed for?

From
Teodor Sigaev
Date:
Opps, sorry, I missed checkpoint keyword

Teodor Sigaev wrote:
> 
>> What am I missing?
> Seems, it's about that
> http://archives.postgresql.org/pgsql-committers/2005-06/msg00085.php
> 

-- 
Teodor Sigaev                                   E-mail: teodor@sigaev.ru
  WWW: http://www.sigaev.ru/
 


Re: What is CheckPoint.undo needed for?

From
Heikki Linnakangas
Date:
No you're right, it's related to the WAL undo stuff that was never 
actually implemented. It's dead code.

Teodor Sigaev wrote:
> Opps, sorry, I missed checkpoint keyword
> 
> Teodor Sigaev wrote:
>>
>>> What am I missing?
>> Seems, it's about that
>> http://archives.postgresql.org/pgsql-committers/2005-06/msg00085.php
>>
> 


--   Heikki Linnakangas  EnterpriseDB   http://www.enterprisedb.com


Re: What is CheckPoint.undo needed for?

From
"Florian G. Pflug"
Date:
Heikki Linnakangas wrote:
> No you're right, it's related to the WAL undo stuff that was never 
> actually implemented. It's dead code.
> 
> Teodor Sigaev wrote:
>> Opps, sorry, I missed checkpoint keyword
>>
>> Teodor Sigaev wrote:
>>>
>>>> What am I missing?
>>> Seems, it's about that
>>> http://archives.postgresql.org/pgsql-committers/2005-06/msg00085.php

Thanks - everything makes much more sense now ;-)

greetings, Florian Pflug


Re: What is CheckPoint.undo needed for?

From
Alvaro Herrera
Date:
Florian G. Pflug wrote:
> Heikki Linnakangas wrote:
> >No you're right, it's related to the WAL undo stuff that was never 
> >actually implemented. It's dead code.
> >
> >Teodor Sigaev wrote:
> >>Opps, sorry, I missed checkpoint keyword
> >>
> >>Teodor Sigaev wrote:
> >>>
> >>>>What am I missing?
> >>>Seems, it's about that
> >>>http://archives.postgresql.org/pgsql-committers/2005-06/msg00085.php
> 
> Thanks - everything makes much more sense now ;-)

So if you want to submit a patch to remove it, it'll make sense for
future readers as well ;-)

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


Re: What is CheckPoint.undo needed for?

From
"Florian G. Pflug"
Date:
Alvaro Herrera wrote:
> Florian G. Pflug wrote:
>> Heikki Linnakangas wrote:
>>> No you're right, it's related to the WAL undo stuff that was never
>>> actually implemented. It's dead code.
>>>
>>> Teodor Sigaev wrote:
>>>> Opps, sorry, I missed checkpoint keyword
>>>>
>>>> Teodor Sigaev wrote:
>>>>>> What am I missing?
>>>>> Seems, it's about that
>>>>> http://archives.postgresql.org/pgsql-committers/2005-06/msg00085.php
>> Thanks - everything makes much more sense now ;-)
>
> So if you want to submit a patch to remove it, it'll make sense for
> future readers as well ;-)

Here you go. I'm not subscribe to pgsql-patches, so I posted this here.

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    22 Feb 2007 15:47:52 -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    22 Feb 2007 15:47:52 -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/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    22 Feb 2007 15:47:53 -0000
@@ -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 */

Re: What is CheckPoint.undo needed for?

From
Alvaro Herrera
Date:
Florian G. Pflug wrote:
> Alvaro Herrera wrote:
> >Florian G. Pflug wrote:
> >>Heikki Linnakangas wrote:
> >>>No you're right, it's related to the WAL undo stuff that was never 
> >>>actually implemented. It's dead code.
> >>>
> >>>Teodor Sigaev wrote:
> >>>>Opps, sorry, I missed checkpoint keyword
> >>>>
> >>>>Teodor Sigaev wrote:
> >>>>>>What am I missing?
> >>>>>Seems, it's about that
> >>>>>http://archives.postgresql.org/pgsql-committers/2005-06/msg00085.php
> >>Thanks - everything makes much more sense now ;-)
> >
> >So if you want to submit a patch to remove it, it'll make sense for
> >future readers as well ;-)
> 
> Here you go. I'm not subscribe to pgsql-patches, so I posted this here.

I think you should increase pg_control version.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


Re: What is CheckPoint.undo needed for?

From
Tom Lane
Date:
Alvaro Herrera <alvherre@commandprompt.com> writes:
> I think you should increase pg_control version.

And the WAL page-header version, since this also changes WAL contents.
        regards, tom lane


Re: What is CheckPoint.undo needed for?

From
"Florian G. Pflug"
Date:
Tom Lane wrote:
> Alvaro Herrera <alvherre@commandprompt.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 */

Re: What is CheckPoint.undo needed for?

From
Bruce Momjian
Date:
Your patch has been added to the PostgreSQL unapplied patches list at:
http://momjian.postgresql.org/cgi-bin/pgpatches

It will be applied as soon as one of the PostgreSQL committers reviews
and approves it.

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


Florian G. Pflug wrote:
> Tom Lane wrote:
> > Alvaro Herrera <alvherre@commandprompt.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@postgresql.org so that your
>        message can get through to the mailing list cleanly

--  Bruce Momjian  <bruce@momjian.us>          http://momjian.us EnterpriseDB
http://www.enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +


Re: What is CheckPoint.undo needed for?

From
Bruce Momjian
Date:
Patch applied.  Thanks.

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


Florian G. Pflug wrote:
> Tom Lane wrote:
> > Alvaro Herrera <alvherre@commandprompt.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@postgresql.org so that your
>        message can get through to the mailing list cleanly

--  Bruce Momjian  <bruce@momjian.us>          http://momjian.us EnterpriseDB
http://www.enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +


Re: What is CheckPoint.undo needed for?

From
Bruce Momjian
Date:
Patch applied.  Thanks.

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


Florian G. Pflug wrote:
> Tom Lane wrote:
> > Alvaro Herrera <alvherre@commandprompt.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@postgresql.org so that your
>        message can get through to the mailing list cleanly

--  Bruce Momjian  <bruce@momjian.us>          http://momjian.us EnterpriseDB
http://www.enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +