pgsql: Don't archive bogus recycled or preallocated files after timelin

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Don't archive bogus recycled or preallocated files after timelin
Date: 2015-04-13 14:56:54
Message-ID: E1YhfnC-0004XC-R6@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Don't archive bogus recycled or preallocated files after timeline switch.

After a timeline switch, we would leave behind recycled WAL segments that
are in the future, but on the old timeline. After promotion, and after they
become old enough to be recycled again, we would notice that they don't have
a .ready or .done file, create a .ready file for them, and archive them.
That's bogus, because the files contain garbage, recycled from an older
timeline (or prealloced as zeros). We shouldn't archive such files.

This could happen when we're following a timeline switch during replay, or
when we switch to new timeline at end-of-recovery.

To fix, whenever we switch to a new timeline, scan the data directory for
WAL segments on the old timeline, but with a higher segment number, and
remove them. Those don't belong to our timeline history, and are most
likely bogus recycled or preallocated files. They could also be valid files
that we streamed from the primary ahead of time, but in any case, they're
not needed to recover to the new timeline.

Branch
------
REL9_0_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/5b6938186a4a9608bd278409c2c3ee5afe6ad0c8

Modified Files
--------------
src/backend/access/transam/xlog.c | 284 +++++++++++++++++++++++++------------
1 file changed, 197 insertions(+), 87 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2015-04-13 15:12:08 pgsql: Refactor and fix TAP tests of pg_rewind
Previous Message Fujii Masao 2015-04-13 04:43:41 Re: pgsql: Mark the second argument of pg_log as the translatable string in