Re: Fwd: Re: [HACKERS] For Review: Allow WAL information to recover

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: yuanjia lee <yuanjia_pg(at)yahoo(dot)com>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Fwd: Re: [HACKERS] For Review: Allow WAL information to recover
Date: 2005-08-19 13:43:05
Message-ID: 200508191343.j7JDh5H00620@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches


Attached is a patch the author had trouble posting that adds a -r
(recover) option to pg_resetxlog. I will put this in the 8.2 queue
along with the original message.

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

yuanjia lee wrote:
> > > I had added an option -r to pg_resetxlog to enable
> > the tool can rebuild the corrupted pg_control file
> > from the old xlog files.
> > >
> > > here is the patch. Sorry I had tried to attached
> > it to the mail, but it failed, I dont know why, here
> > is the
> >
> link:http://www.geocities.com/yuanjia_pg/pg_resetxlog.diff.txt
> > >
> > > There are also some changes in the logic of other
> > options.
> > > Option -n: only print out the control values in
> > the existing pg_control file, if the file is
> > corrupted , inform the use to rebuild it first only.
> > > Option -f: if pg_control file is fine, then reset
> > the xlog file; if pg_control is corrupted , then try
> > to rebuild the control file from old xlog file, if
> > it fails, then just guessing the value, then reset
> > the xlog file.
> > >
> > > The algorithm of restoring the pg_control value
> > from old xlog file:
> > > 1. Retrieve all of the active xlog files from
> > xlog directory into a list by increasing order,
> > according their timeline, log id, segment id. (Tom
> > had informed me that we can not know which segment
> > file is latest just by the name itself, so before
> > adding the segment file to the list, it should be
> > checked that it is an active segment file.)
> > > 2. Search the list to find the oldest xlog file of
> > the latest time line. (Although it is better to let
> > the user to select the time line which is used for
> > rebuild the xlog file, but I think there is not so
> > necessary. I had tried to use only the last file in
> > the latest time line, but I found that in many
> > cases, there are possible that the last checkpoint
> > record and the previous checkpoint record are stored
> > separately in different segment file, so I had to
> > search from the oldest one.)
> > > 3. Search the records from the oldest xlog file of
> > latest time line to the latest xlog file of latest
> > time line, if the checkpoint record has been found,
> > update the latest checkpoint and previous
> > checkpoint.
> > >
> > > Some of the code is borrowed from Tom Lane
> > xlogdump.c file.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 35.4 KB

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2005-08-20 16:17:47 Re: Win32 unicode vs ICU
Previous Message Johnny C. Lam 2005-08-17 23:14:20 Re: pthread stack on FreeBSD WAS: HEAD doesn't cope with