Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Yl0J4-00061z-3V for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Apr 2015 19:27:34 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Yl0J3-0007zW-Ex for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Apr 2015 19:27:33 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Yl0J1-0007zL-SU for pgsql-hackers@postgresql.org; Wed, 22 Apr 2015 19:27:32 +0000 Received: from mail-qk0-x235.google.com ([2607:f8b0:400d:c09::235]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1Yl0Iy-0000KP-Fe for pgsql-hackers@postgresql.org; Wed, 22 Apr 2015 19:27:30 +0000 Received: by qkhg7 with SMTP id g7so236809796qkh.2 for ; Wed, 22 Apr 2015 12:27:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=IYKqv9ty95cwgxc3IqjNOhNFicatE2aKGKxaUPf9tBw=; b=BlKZMzXrwMJKh1jiLE54XKIYKYPbVHkH78x5Kk9XqV04wgfizLEY498SZL2bYdd29q 0okR4M6gRpzqtJlS8QmkcYv2ezdJwe2UJpfZdNJuynHQQE1ezyN3w7s/DntwR+Y8581Z PMxnDpDIMHmjDr/X9+NRmcH4wS0BQzpXWzo5mg/cX/kLrj+xwpJzlneIol4il72L5t5o QvcCNgQ0IQss7uVSXt6gxEY1FO1Bi9xYgNpAikLGc9U5Q+C9Wh6Ip/8WZy0kBbcZO/Nl mIinFeGmUzTDvoF+VxJkkI8ciHm8OhRL6Oivd9uoUBPQnq18rQwIsvoU2jlgUSmLPIcA 7vcA== MIME-Version: 1.0 X-Received: by 10.55.50.20 with SMTP id y20mr52026155qky.58.1429730466647; Wed, 22 Apr 2015 12:21:06 -0700 (PDT) Received: by 10.140.250.139 with HTTP; Wed, 22 Apr 2015 12:21:06 -0700 (PDT) In-Reply-To: <5537EFEF.6060808@iki.fi> References: <548AF1CB.80702@vmware.com> <689EB259-44C2-4820-B901-4F6B1C55A1E4@simply.name> <549083D6.1000301@vmware.com> <54949108.3030109@vmware.com> <552FA38F.9060005@iki.fi> <5535FE71.1010905@iki.fi> <55362CAD.2000207@iki.fi> <55373D17.5050706@iki.fi> <5537EFEF.6060808@iki.fi> Date: Wed, 22 Apr 2015 15:21:06 -0400 Message-ID: Subject: Re: Streaming replication and WAL archive interactions From: Robert Haas To: hlinnaka Cc: Michael Paquier , Venkata Balaji N , Andres Freund , Fujii Masao , Borodin Vladimir , PostgreSQL-development Content-Type: text/plain; charset=UTF-8 X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On Wed, Apr 22, 2015 at 3:01 PM, Heikki Linnakangas wrote: > On 04/22/2015 09:30 PM, Robert Haas wrote: >> On Wed, Apr 22, 2015 at 2:17 AM, Heikki Linnakangas >> wrote: >>> >>> Note that it's a bit complicated to set up that scenario today. Archiving >>> is >>> never enabled in recovery mode, so you'll need to use a custom cron job >>> or >>> something to maintain the archive that C uses. The files will not >>> automatically flow from B to the second archive. With the patch we're >>> discussing, however, it would be easy: just set archive_mode='always' in >>> B. >> >> >> Hmm, I see. But if C never replays the last, partial segment from the >> old timeline, how does it follow the timeline switch? > > At timeline switch, we copy the old segment to the new timeline, and start > writing where we left off. So the WAL from the old timeline is found in the > segment nominally belonging to the new timeline. Check. > For example, imagine that perform point-in-time recovery to WAL position > 0/1237E568, on timeline 1. That falls within segment > 000000010000000000000012. Then we end recovery, and switch to timeline 2. > After the switch, and some more WAL-logged actions, we'll have these files > in pg_xlog: > > 000000010000000000000011 > 000000010000000000000012 > 000000020000000000000012 > 000000020000000000000013 > 000000020000000000000014 Is the 000000010000000000000012 file a "partial" segment of the sort you're proposing to no longer achive? > Note that there are two segments ending in "12". They both have the same > point up to offset 0x37E568, corresponding to the switch point 0/1237E568. > After that, the contents diverge: the segment on the new timeline contains a > checkpoint/end-of-recovery record at that point, followed by new WAL > belonging to the new timeline. Check. > Recovery knows about that, so that if you set recovery target to timeline 2, > and it needs the WAL at the beginning of segment 12 (still belonging to > timeline 1), it will try to restoring both "000000010000000000000012" and > "000000020000000000000012". What if you set the recovery target to timeline 3? -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers