Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fpbyU-0000fK-Nv for pgsql-general@arkaria.postgresql.org; Tue, 14 Aug 2018 16:15:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fpbyR-0007Wi-J0 for pgsql-general@arkaria.postgresql.org; Tue, 14 Aug 2018 16:15:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fpbyR-0007Wb-AQ for pgsql-general@lists.postgresql.org; Tue, 14 Aug 2018 16:15:11 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fpbyJ-0000k4-S7 for pgsql-general@lists.postgresql.org; Tue, 14 Aug 2018 16:15:10 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w7EGEx8Q001888; Tue, 14 Aug 2018 12:14:59 -0400 From: Tom Lane To: Mike Cardwell cc: pgsql-general@lists.postgresql.org Subject: Re: pg_basebackup failed to read a file In-reply-to: <1534256304.6834.4.camel@hardenize.com> References: <1534256304.6834.4.camel@hardenize.com> Comments: In-reply-to Mike Cardwell message dated "Tue, 14 Aug 2018 15:18:24 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <1886.1534263299.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 14 Aug 2018 12:14:59 -0400 Message-ID: <1887.1534263299@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Mike Cardwell writes: > pg_basebackup: could not get write-ahead log end position from server: > ERROR:=C2=A0=C2=A0could not open file "./postgresql.conf~": Permission d= enied > Now, I know what this error means. There was a root owned file at > "/var/lib/pgsql/10/data/postgresql.conf~" which contained an old > version of our postgres config and was not readable by the postgres > user. I'll delete this file and try again. However, in the mean time: I > feel like it would be useful for pg_basebackup to check that it has > read access to all of the existing files in the source directory at the > start, before it begins it's copy. That seems like a pretty expensive thing to do, if there are lots of files ... and you'd still end up failing, so it's not moving the ball very far. More generally, this seems closely related to bug #14999 [1] which concerned pg_rewind's behavior in the face of unexpected file permissions within the data directory. We ended up not doing anything about that except documenting it, which I wasn't very satisfied with, but the costs of doing better seemed to exceed the benefits. It'd be nice to have a more coherent theory about what needs to be copied or not, and not fail on files that could simply be ignored. Up to now we've resisted having any centrally defined knowledge of what can be inside a PG data directory, but maybe that bullet needs to be bitten. regards, tom lane [1] https://www.postgresql.org/message-id/flat/20180104200633.17004.16377%= 40wrigleys.postgresql.org