Skip site navigation (1) Skip section navigation (2)

pgsql: Tolerate timeline switches while "pg_basebackup -X fetch" isrun

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Tolerate timeline switches while "pg_basebackup -X fetch" isrun
Date: 2013-01-03 18:01:41
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-committerspgsql-hackers
Tolerate timeline switches while "pg_basebackup -X fetch" is running.

If you take a base backup from a standby server with "pg_basebackup -X
fetch", and the timeline switches while the backup is being taken, the
backup used to fail with an error "requested WAL segment %s has already
been removed". This is because the server-side code that sends over the
required WAL files would not construct the WAL filename with the correct
timeline after a switch.

Fix that by using readdir() to scan pg_xlog for all the WAL segments in the
range, regardless of timeline.

Also, include all timeline history files in the backup, if taken with
"-X fetch". That fixes another related bug: If a timeline switch happened
just before the backup was initiated in a standby, the WAL segment
containing the initial checkpoint record contains WAL from the older
timeline too. Recovery will not accept that without a timeline history file
that lists the older timeline.

Backpatch to 9.2. Versions prior to that were not affected as you could not
take a base backup from a standby before 9.2.



Modified Files
src/backend/access/transam/xlog.c    |   27 +++-
src/backend/replication/basebackup.c |  234 ++++++++++++++++++++++++++++------
src/backend/replication/walsender.c  |   15 +--
src/include/access/xlog.h            |    2 +-
4 files changed, 217 insertions(+), 61 deletions(-)


pgsql-hackers by date

Next:From: Josh BerkusDate: 2013-01-03 18:35:22
Subject: Re: Feature Request: pg_replication_master()
Previous:From: Tom LaneDate: 2013-01-03 17:58:01
Subject: pg_upgrade test script creates port conflicts in parallel testing

pgsql-committers by date

Next:From: Tom LaneDate: 2013-01-03 23:35:11
Subject: pgsql: Prevent creation of postmaster's TCP socket during pg_upgradete
Previous:From: Bruce MomjianDate: 2013-01-03 02:20:54
Subject: pgsql: Adjust a few pg_upgrade functions to return void.

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group