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

From: "Mikael Krantz" <mk(at)zigamorph(dot)se>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #4796: Recovery followed by backup creates unrecoverable WAL-file
Date: 2009-05-06 13:22:02
Message-ID: 200905061322.n46DM2s2087842@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers


The following bug has been logged online:

Bug reference: 4796
Logged by: Mikael Krantz
Email address: mk(at)zigamorph(dot)se
PostgreSQL version: 8.3.7-0lenny1
Operating system: Linux (debian lenny)
Description: Recovery followed by backup creates unrecoverable
WAL-file
Details:

If you perform a recovery form a file system level backup postgres will
switch to a new timeline but the first WAL-log in with the new timeline will
contain the previous timeline.

If you start a backup immediately after recovery have completed the start of
the backup will be in this bad WAL file. This makes the backup unrecoverable
as it will fail with an error similar to:

LOG: unexpected timeline ID 54 in log file 4, segment 236, offset 0
LOG: invalid checkpoint record
PANIC: could not locate required checkpoint record
HINT: If you are not restoring from a backup, try removing the file
"/var/lib/postgresql/8.3/main/backup_label".

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

It is also visible in the first WAL-file of a new timeline:
# od -t x4 /var/lib/postgresql/8.3/main/pg_xlog/0000003D0000000500000001
|head -1
0000000 0002d062 0000003c 00000005 01000000

The timeline tag 0000003c is in a file named 0000003D which causes it to be
unrecoverable.

Workaround:

Wait for or force a xlog switch before pg_start_backup. Possibly a simple
fix would be to make pg_start_backup force this switch automatically.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2009-05-06 14:33:11 Re: Bug (8.4beta): FailedAssertion("!(bms_is_subset(relids, qualscope))", File: "initsplan.c", Line: 915)
Previous Message Madhu S R 2009-05-06 11:04:18 BUG #4795: Solaris odbc Core Dump on Column NULL value

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2009-05-06 13:30:49 Re: create if not exists (CINE)
Previous Message Dawid Kuroczko 2009-05-06 13:04:50 Re: create if not exists (CINE)