Re: exitArchiveRecovery woes

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: exitArchiveRecovery woes
Date: 2014-12-18 15:49:28
Message-ID: 5492F788.4010801@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 12/18/2014 03:53 PM, Robert Haas wrote:
> On Wed, Dec 17, 2014 at 8:40 AM, Heikki Linnakangas
> <hlinnakangas(at)vmware(dot)com> wrote:
>> At the end of archive recovery, we copy the last segment from the old
>> timeline, to initialize the first segment on the new timeline. For example,
>> if the timeline switch happens in the middle of WAL segment
>> 000000010000000000000005, the whole 000000010000000000000005 segment is
>> copied to become 000000020000000000000005. The copying is necessary, so that
>> the new segment contains valid data up to the switch point.
>>
>> However, we wouldn't really need to copy the whole segment, copying up to
>> the switch point would be enough. In fact, copying the whole segment is a
>> bad idea, because the copied WAL looks valid on the new timeline too.
>
> Your proposed change makes sense to me, but why do we need the segment
> to contain valid data up to the switch point? It seems like the
> switch between timelines should be "crisper": replay WAL on the old
> timeline only from the old segment, and from the new timeline only on
> the new segment. Anything else seems like an invitation to unending
> corner-case bugs.

True. That would require some changes to the way archive recovery works,
though. Currently, when our recovery target timeline is, for example, 5,
whose parents are 4 and 3, and we're currently on timeline 3, we will
try to restore each segment first with timeline ID 5, then 4, then 3.
It's a bit silly, because we know the timeline history and the exact
points where the timelines changed, so we could just fetch the correct
one. That would be a good idea, but I'm going to go ahead with just this
smaller change now.

- Heikki

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2014-12-18 15:51:35 Re: INSERT ... ON CONFLICT {UPDATE | IGNORE}
Previous Message Kevin Grittner 2014-12-18 15:46:19 Re: INSERT ... ON CONFLICT {UPDATE | IGNORE}