Re: BUG #4796: Recovery followed by backup creates unrecoverable WAL-file

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Mikael Krantz <mk(at)zigamorph(dot)se>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4796: Recovery followed by backup creates unrecoverable WAL-file
Date: 2009-05-07 09:15:38
Message-ID: 4A02A6BA.1030306@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Mikael Krantz wrote:
> On Wed, May 6, 2009 at 6:26 PM, Heikki Linnakangas
> <heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
>>> How to reproduce:
>>>
>>> * restore from backup
>>> * SELECT pg_start_backup('label');
>>> * take a new backup
>>> * SELECT pg_stop_backup();
>>> * copy the relevant WAL-files
>>> * try to restore the backup
>> I failed to reproduce this. Is it possible that the history file went
>> missing in the process? That's needed to recover WAL files from timelines
>> other than the latest one. You should only get that "unexpected timeline ID"
>> message if the history file doesn't contain a line for that timeline ID.
>
> Yes that's true. The history file is not included in the backup. It is
> archived before the backup starts and is not included in the
> range specified in the backup file (e.g:
> 0000003B00000004000000FC.00000020.backup).
>
> Doesn't this mean that the range of log-files in the backup file is
> incorrect? If the first WAL-file in the range contain records
> referring to earlier timelines I will have to backup the .history-file
> of that timeline in addition to the WAL-files explicitly required for
> the backup. Or force a switch of log-files before starting the backup
> as I'm currently doing.

Yeah, I think you're right. If you omit pg_xlog from the base backup, as
we recommend in the manual, and clear the old files from the archive
too, then you won't have the old history file around.

I'll make pg_start_backup() to request xlog switch before the checkpoint
as you suggested. That's an easy fix that can be easily back-patched.

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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Heikki Linnakangas 2009-05-07 11:34:53 Re: BUG #4796: Recovery followed by backup creates unrecoverable WAL-file
Previous Message Dave Page 2009-05-07 08:30:48 Re: BUG #4785: Installation fails

Browse pgsql-hackers by date

  From Date Subject
Next Message Laurent Laborde 2009-05-07 09:25:15 Re: create if not exists (CINE)
Previous Message Mikael Krantz 2009-05-07 07:56:23 Re: BUG #4796: Recovery followed by backup creates unrecoverable WAL-file