Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YkztY-00056o-7r for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Apr 2015 19:01:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YkztX-0003eE-No for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Apr 2015 19:01:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YkztW-0003du-Kk for pgsql-hackers@postgresql.org; Wed, 22 Apr 2015 19:01:10 +0000 Received: from mail-wi0-x22f.google.com ([2a00:1450:400c:c05::22f]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YkztT-0000sH-2G for pgsql-hackers@postgresql.org; Wed, 22 Apr 2015 19:01:09 +0000 Received: by wizk4 with SMTP id k4so189620616wiz.1 for ; Wed, 22 Apr 2015 12:01:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:reply-to:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=ZzffFsui0AuOmT9nd3qQVlOuyxIbOqCtO8clZEnqgaY=; b=rEskLt0dD58+2fRnsDj7ABLxfVD6ahwAzivAqoS/w3u0LdfFHIXIoTeepRaFSDOZNS +sfKKabFpQXlwYgi8jLNiL0wAJzP74na2TTGiijnlEtAgLMDguydqGq6xrGEQlZlX7VF 1pV5lYV+ALgDAE7DYfvQpqO32EqNx9IjGgoCKTV87WsdD1Czu7WQhF/P0zsfOh7YtCf+ FrLl61e8GQ9Wbj8+T19LcwTrsEVd4pj9+1cb/T8UHQ8IR6tUPVr0J9Y1yVWifynWYDxI 3oh0VHVLqmtAZi5P6QovUD0HLy/Bu1d2ermuHIChhnUB2QCnU4Ocjebg7hBZtH8z+nnK fKrw== X-Received: by 10.181.13.198 with SMTP id fa6mr8691396wid.41.1429729266278; Wed, 22 Apr 2015 12:01:06 -0700 (PDT) Received: from [192.168.1.99] (dsl-hkibrasgw1-58c38f-82.dhcp.inet.fi. [88.195.143.82]) by mx.google.com with ESMTPSA id ub1sm8533156wjc.43.2015.04.22.12.01.04 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2015 12:01:05 -0700 (PDT) Message-ID: <5537EFEF.6060808@iki.fi> Date: Wed, 22 Apr 2015 22:01:03 +0300 From: Heikki Linnakangas Reply-To: hlinnaka@iki.fi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.6.0 MIME-Version: 1.0 To: Robert Haas CC: Michael Paquier , Venkata Balaji N , Andres Freund , Fujii Masao , Borodin Vladimir , PostgreSQL-development Subject: Re: Streaming replication and WAL archive interactions 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> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.4 (--) 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 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. 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 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. 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". - Heikki -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers