Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tm2ni-0003Rl-TP for pgsql-bugs@arkaria.postgresql.org; Fri, 21 Dec 2012 13:38:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Tm2ni-0002Ka-EQ for pgsql-bugs@arkaria.postgresql.org; Fri, 21 Dec 2012 13:38:10 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tm2nh-0002KV-OA for pgsql-bugs@postgresql.org; Fri, 21 Dec 2012 13:38:09 +0000 Received: from smtp-outbound-1.vmware.com ([208.91.2.12]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tm2nf-0007Zi-Fm for pgsql-bugs@postgresql.org; Fri, 21 Dec 2012 13:38:08 +0000 Received: from sc9-mailhost3.vmware.com (sc9-mailhost3.vmware.com [10.113.161.73]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id 78C4028445; Fri, 21 Dec 2012 05:38:06 -0800 (PST) Received: from zcs-prod-ext-mta-2.vmware.com (zcs-prod-ext-mta-2.vmware.com [10.113.62.224]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 743874008C; Fri, 21 Dec 2012 05:38:06 -0800 (PST) Received: from localhost (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-2.vmware.com (Postfix) with ESMTP id 188BEC1533; Fri, 21 Dec 2012 05:38:06 -0800 (PST) X-Virus-Scanned: amavisd-new at zcs-prod-ext-mta-2.vmware.com Received: from zcs-prod-ext-mta-2.vmware.com ([127.0.0.1]) by localhost (zcs-prod-ext-mta-2.vmware.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1t43fXTq91zD; Fri, 21 Dec 2012 05:38:06 -0800 (PST) Received: from localhost (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-2.vmware.com (Postfix) with ESMTP id E5EF7C1534; Fri, 21 Dec 2012 05:38:05 -0800 (PST) X-Virus-Scanned: amavisd-new at zcs-prod-ext-mta-2.vmware.com Received: from zcs-prod-ext-mta-2.vmware.com ([127.0.0.1]) by localhost (zcs-prod-ext-mta-2.vmware.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id VTqkhfRQeNif; Fri, 21 Dec 2012 05:38:05 -0800 (PST) Received: from [192.168.1.90] (unknown [10.113.62.14]) by zcs-prod-ext-mta-2.vmware.com (Postfix) with ESMTPSA id 31720C1533; Fri, 21 Dec 2012 05:38:05 -0800 (PST) Message-ID: <50D46642.6010008@vmware.com> Date: Fri, 21 Dec 2012 15:38:10 +0200 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.10) Gecko/20121027 Icedove/10.0.10 MIME-Version: 1.0 To: Magnus Hagander CC: Pg Bugs Subject: Re: pg_basebackup fails if a data file is removed References: <50D463E8.9000000@vmware.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -6.9 (------) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 21.12.2012 15:30, Magnus Hagander wrote: > On Fri, Dec 21, 2012 at 2:28 PM, Heikki Linnakangas > wrote: >> When pg_basebackup copies data files, it does basically this: >> >>> if (lstat(pathbuf,&statbuf) != 0) >>> { >>> if (errno != ENOENT) >>> ereport(ERROR, >>> (errcode_for_file_access(), >>> errmsg("could not stat file or directory >>> \"%s\": %m", >>> pathbuf))); >>> >>> /* If the file went away while scanning, it's no error. */ >>> continue; >>> } >> >>> ... >>> sendFile(pathbuf, pathbuf + basepathlen + 1,&statbuf); >> >> There's a race condition there. If the file is removed after the lstat call, >> and before sendFile opens the file, the backup fails with an error. It's a >> fairly tight window, so it's difficult to run into by accident, but by >> putting a breakpoint with a debugger there it's quite easy to reproduce, by >> e.g doing a VACUUM FULL on the table about to be copied. >> >> A straightforward fix is to allow sendFile() to ignore ENOENT. Patch >> attached. > > Looks good to me. Ok, committed. > Nice spot - don't tell me you actually ran into it > during testing? :) Heh, no, eyeballing the code. - Heikki -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs