Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 77068B5DC01 for ; Fri, 23 Sep 2011 06:05:49 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 92214-06 for ; Fri, 23 Sep 2011 09:05:42 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from exprod7og117.obsmtp.com (exprod7og117.obsmtp.com [64.18.2.6]) by mail.postgresql.org (Postfix) with ESMTP id F01B6B5DC09 for ; Fri, 23 Sep 2011 06:05:41 -0300 (ADT) Received: from mail-fx0-f49.google.com ([209.85.161.49]) (using TLSv1) by exprod7ob117.postini.com ([64.18.6.12]) with SMTP ID DSNKTnxL5cyiwSkanPRN+8sKe3Y0dAKMMwis@postini.com; Fri, 23 Sep 2011 02:05:42 PDT Received: by mail-fx0-f49.google.com with SMTP id 7so3951734fxg.8 for ; Fri, 23 Sep 2011 02:05:41 -0700 (PDT) Received: by 10.223.14.133 with SMTP id g5mr4644952faa.69.1316768740095; Fri, 23 Sep 2011 02:05:40 -0700 (PDT) Received: from [192.168.1.183] (dsl-hkibrasgw2-ff7ac300-240.dhcp.inet.fi. [88.195.122.240]) by mx.google.com with ESMTPS id y24sm10385991fan.24.2011.09.23.02.05.37 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 23 Sep 2011 02:05:39 -0700 (PDT) Message-ID: <4E7C4BE0.4060701@enterprisedb.com> Date: Fri, 23 Sep 2011 12:05:36 +0300 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.2.21) Gecko/20110831 Icedove/3.1.13 MIME-Version: 1.0 To: Florian Pflug CC: Linas Virbalas , Euler Taveira de Oliveira , Robert Haas , "pgsql-hackers@postgresql.org" Subject: Re: Hot Backup with rsync fails at pg_clog if under load References: <4E7C4638.1060103@enterprisedb.com> <647BE58F-ED68-497C-8122-237E6327C075@phlo.org> In-Reply-To: <647BE58F-ED68-497C-8122-237E6327C075@phlo.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201109/1179 X-Sequence-Number: 195368 On 23.09.2011 11:48, Florian Pflug wrote: > On Sep23, 2011, at 10:41 , Heikki Linnakangas wrote: >> On 23.09.2011 11:02, Linas Virbalas wrote: >>> On 9/22/11 6:59 PM, "Euler Taveira de Oliveira" wrote: >>> >>>>> If needed, I could do that, if I had the exact procedure... Currently, >>>>> during the start of the backup I take the following information: >>>>> >>>> Just show us the output of pg_start_backup and part of the standby log with >>>> the following message 'redo starts at' and the subsequent messages up to the >>>> failure. >>> >>> Unfortunately, it's impossible, because the error message "Could not read >>> from file "pg_clog/0001" at offset 32768: Success" is shown (and startup >>> aborted) before the turn for "redo starts at" message arrives. >> >> It looks to me that pg_clog/0001 exists, but it shorter than recovery expects. Which shouldn't happen, of course, because the start-backup checkpoint should flush all the clog that's needed by recovery to disk before the backup procedure begins to them. > > Yeah. What confuses me though is that we fail while trying to read from the clog. When do we do that during normal (non-standby) recovery? I believe the OP is setting up a standby. He didn't say if it's a hot standby, though. That changes the startup sequence a bit. At the end of recovery, we read the "last" clog page, containing the next XID that will be assigned to a transaction, and zero out the future part of that clog file (StartupCLOG). In hot standby, we do that earlier, after reading the checkpoint record but before we start replaying records. > One other possibility would be that the problem is somehow triggered by vacuum running while the start-backup checkpoint is commencing. That'd explain why the problem goes away with immediate checkpoints, because those make the windows mach smaller. But I haven't got a concrete theory of whats happening.. Hmm, that's a good theory. The logic in SimpleLruPhysicakReadPage() tolerates non-existent files, because the old clog files might've been truncated away by a vacuum after the backup started. That's OK, because they will be recreated, and later deleted again, during the WAL replay. But what if something like this happens: 0. pg_start_backup(). 1. rsync starts. It gets a list of all files. It notes that pg_clog/0001 exists. 2. vacuum runs, and deletes pg_clog/0001 3. rsync starts to copy pg_clog/0001. Oops, it's gone. Instead of leaving it out altogether, it includes it as an empty file. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com