Re: pg_basebackup: could not get transaction log end position from server: FATAL: could not open file "./pg_hba.conf~": Permission denied

Lists: pgsql-hackers
From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: pg_basebackup: could not get transaction log end position from server: FATAL: could not open file "./pg_hba.conf~": Permission denied
Date: 2014-05-16 14:28:42
Message-ID: 5376209A.5040805@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello,

Can we get that fixed please? It seems rather bad behavior for
pg_basebackup to fatal out because of the permissions on a backup file
of all things. Instead, we should do WARNING and say skipped.

JD


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_basebackup: could not get transaction log end position from server: FATAL: could not open file "./pg_hba.conf~": Permission denied
Date: 2014-05-16 14:30:36
Message-ID: 20140516143036.GE28158@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

On 2014-05-16 07:28:42 -0700, Joshua D. Drake wrote:
> Can we get that fixed please? It seems rather bad behavior for pg_basebackup
> to fatal out because of the permissions on a backup file of all things.
> Instead, we should do WARNING and say skipped.

Doesn't sound like a good idea to me. We'd need to have a catalog of
common unimportant fileendings and such. We surely *do* want to error
out when we fail to copy an important file.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_basebackup: could not get transaction log end position from server: FATAL: could not open file "./pg_hba.conf~": Permission denied
Date: 2014-05-16 15:13:04
Message-ID: 53762B00.5070008@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 05/16/2014 07:30 AM, Andres Freund wrote:
>
> Hi,
>
> On 2014-05-16 07:28:42 -0700, Joshua D. Drake wrote:
>> Can we get that fixed please? It seems rather bad behavior for pg_basebackup
>> to fatal out because of the permissions on a backup file of all things.
>> Instead, we should do WARNING and say skipped.
>
> Doesn't sound like a good idea to me. We'd need to have a catalog of
> common unimportant fileendings and such. We surely *do* want to error
> out when we fail to copy an important file.they
>

pg_hba.conf~ is not an important file.

We know what files are important, especially in $PGDATA, they aren't
variable, so why is pg_basebackup failing on a file it should know or
care nothing about?

JD


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_basebackup: could not get transaction log end position from server: FATAL: could not open file "./pg_hba.conf~": Permission denied
Date: 2014-05-16 15:19:03
Message-ID: 4998.1400253543@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Joshua D. Drake" <jd(at)commandprompt(dot)com> writes:
> On 05/16/2014 07:30 AM, Andres Freund wrote:
>> On 2014-05-16 07:28:42 -0700, Joshua D. Drake wrote:
>>> Can we get that fixed please? It seems rather bad behavior for pg_basebackup
>>> to fatal out because of the permissions on a backup file of all things.
>>> Instead, we should do WARNING and say skipped.

>> Doesn't sound like a good idea to me. We'd need to have a catalog of
>> common unimportant fileendings and such. We surely *do* want to error
>> out when we fail to copy an important file.they

> pg_hba.conf~ is not an important file.

Rather than blaming the messenger, you should be asking why there are
files in $PGDATA that the server can't read. That's a recipe for trouble
no matter what.

Or in words of one syllable: this is a bug in your editor, not in Postgres.

regards, tom lane


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_basebackup: could not get transaction log end position from server: FATAL: could not open file "./pg_hba.conf~": Permission denied
Date: 2014-05-16 15:21:39
Message-ID: 20140516152139.GK23662@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-05-16 08:13:04 -0700, Joshua D. Drake wrote:
> On 05/16/2014 07:30 AM, Andres Freund wrote:
> >
> >Hi,
> >
> >On 2014-05-16 07:28:42 -0700, Joshua D. Drake wrote:
> >>Can we get that fixed please? It seems rather bad behavior for pg_basebackup
> >>to fatal out because of the permissions on a backup file of all things.
> >>Instead, we should do WARNING and say skipped.
> >
> >Doesn't sound like a good idea to me. We'd need to have a catalog of
> >common unimportant fileendings and such. We surely *do* want to error
> >out when we fail to copy an important file.they
> >
>
> pg_hba.conf~ is not an important file.

Where do we know that from?

> We know what files are important, especially in $PGDATA, they aren't
> variable, so why is pg_basebackup failing on a file it should know or care
> nothing about?

No, we don't necessarily. It'd e.g. bad to succeed if postgresql.conf
includes another file and we fail when backing that up even though it's
in the data directory.
But even otherwise it'd be a non-neglegible amount of code to enumerate
possibly important files (which wouldn't fully reliable. We can't access
the catalogs). Code that's only there to work around a user doing
something bad that's trivially fixable. Nah.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_basebackup: could not get transaction log end position from server: FATAL: could not open file "./pg_hba.conf~": Permission denied
Date: 2014-05-16 15:45:12
Message-ID: 53763288.70500@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 05/16/2014 08:19 AM, Tom Lane wrote:

>> pg_hba.conf~ is not an important file.
>
> Rather than blaming the messenger, you should be asking why there are
> files in $PGDATA that the server can't read. That's a recipe for trouble
> no matter what.
>
> Or in words of one syllable: this is a bug in your editor, not in Postgres.

Hardly and shows a distinct lack of user space experience. It also shows
how useless pg_basebackup "can" be. Basically you are saying, "Well
yeah, there is this rogue file that doesn't belong, fark it... we will
blow away a 2TB base backup and make you start over because.. meh,
pg_basebackup is lazy."

Software is supposed to make our lives easier, not harder. I should be
able to evaluate the errors for the conditions they create. This is why
rsync is and for the forseeable future will be king for creating base
backups.

JD

>
> regards, tom lane
>
>


From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_basebackup: could not get transaction log end position from server: FATAL: could not open file "./pg_hba.conf~": Permission denied
Date: 2014-05-16 15:46:50
Message-ID: 537632EA.9010908@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

At a minimum:

Check to see if there is going to be a permission error BEFORE the base
backup begins:

starting basebackup:
checking perms: ERROR no access to pg_hba.conf~ base backup will fail

JD


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_basebackup: could not get transaction log end position from server: FATAL: could not open file "./pg_hba.conf~": Permission denied
Date: 2014-05-16 15:48:42
Message-ID: 20140516154842.GL23662@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

On 2014-05-16 08:45:12 -0700, Joshua D. Drake wrote:
> Software is supposed to make our lives easier, not harder. I should be able
> to evaluate the errors for the conditions they create. This is why rsync is
> and for the forseeable future will be king for creating base backups.

It's dangerous to ignore errors rsync errors other than 'file
vanished'. This hardly is an argument for your position.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_basebackup: could not get transaction log end position from server: FATAL: could not open file "./pg_hba.conf~": Permission denied
Date: 2014-05-16 15:53:22
Message-ID: 53763472.2030605@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 05/16/2014 08:48 AM, Andres Freund wrote:
>
> Hi,
>
> On 2014-05-16 08:45:12 -0700, Joshua D. Drake wrote:
>> Software is supposed to make our lives easier, not harder. I should be able
>> to evaluate the errors for the conditions they create. This is why rsync is
>> and for the forseeable future will be king for creating base backups.
>
> It's dangerous to ignore errors rsync errors other than 'file
> vanished'. This hardly is an argument for your position.

Are you reading what I write?

I said. "I should be able to evaluate the errors for the conditions they
create."

I never suggested ignoring anything. The point is RSYNC gives me a
chance at success, pg_basebackup does not (in respect to this specific
condition).

JD


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_basebackup: could not get transaction log end position from server: FATAL: could not open file "./pg_hba.conf~": Permission denied
Date: 2014-05-16 16:20:35
Message-ID: CABUevExW2pb=6KqyttV3=vdVRA9UYj3oEZgDL6afJFh54b24rg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, May 16, 2014 at 5:46 PM, Joshua D. Drake <jd(at)commandprompt(dot)com>wrote:

> At a minimum:
>
> Check to see if there is going to be a permission error BEFORE the base
> backup begins:
>
> starting basebackup:
> checking perms: ERROR no access to pg_hba.conf~ base backup will fail

That's pretty much what it does if you enable progress meter. I realize you
don't necessarily want that one, but we could have a switch that still
tells the server to measure the size, but not actually print the output?
While it costs a bit of overhead to do that, that's certainly something
that's a lot more safe than ignoring errors.

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_basebackup: could not get transaction log end position from server: FATAL: could not open file "./pg_hba.conf~": Permission denied
Date: 2014-05-16 16:25:26
Message-ID: 20140516162526.GM23662@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-05-16 18:20:35 +0200, Magnus Hagander wrote:
> On Fri, May 16, 2014 at 5:46 PM, Joshua D. Drake <jd(at)commandprompt(dot)com>wrote:
>
> > At a minimum:
> >
> > Check to see if there is going to be a permission error BEFORE the base
> > backup begins:
> >
> > starting basebackup:
> > checking perms: ERROR no access to pg_hba.conf~ base backup will fail
>
>
> That's pretty much what it does if you enable progress meter. I realize you
> don't necessarily want that one, but we could have a switch that still
> tells the server to measure the size, but not actually print the output?
> While it costs a bit of overhead to do that, that's certainly something
> that's a lot more safe than ignoring errors.

Don't think it'll show you that error - that mode only stats() files,
right? So you'd need to add access() or open()s.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_basebackup: could not get transaction log end position from server: FATAL: could not open file "./pg_hba.conf~": Permission denied
Date: 2014-05-16 16:29:25
Message-ID: CABUevEw34wgHBP7+Qpb+NXokf6L7G9e6S4cfpbog++Bn378y_Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, May 16, 2014 at 6:25 PM, Andres Freund <andres(at)2ndquadrant(dot)com>wrote:

> On 2014-05-16 18:20:35 +0200, Magnus Hagander wrote:
> > On Fri, May 16, 2014 at 5:46 PM, Joshua D. Drake <jd(at)commandprompt(dot)com
> >wrote:
> >
> > > At a minimum:
> > >
> > > Check to see if there is going to be a permission error BEFORE the base
> > > backup begins:
> > >
> > > starting basebackup:
> > > checking perms: ERROR no access to pg_hba.conf~ base backup will fail
> >
> >
> > That's pretty much what it does if you enable progress meter. I realize
> you
> > don't necessarily want that one, but we could have a switch that still
> > tells the server to measure the size, but not actually print the output?
> > While it costs a bit of overhead to do that, that's certainly something
> > that's a lot more safe than ignoring errors.
>
> Don't think it'll show you that error - that mode only stats() files,
> right? So you'd need to add access() or open()s.
>
>
You're right, we don't. I thought we did, but was clearly remembering wrong.

I guess we could add an access() call to that codepath though. Not sure if
that's going to cause any real overhead compared to the rest of what we're
doing anyway?

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_basebackup: could not get transaction log end position from server: FATAL: could not open file "./pg_hba.conf~": Permission denied
Date: 2014-05-16 16:32:26
Message-ID: 20140516163226.GN23662@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2014-05-16 18:29:25 +0200, Magnus Hagander wrote:
> On Fri, May 16, 2014 at 6:25 PM, Andres Freund <andres(at)2ndquadrant(dot)com>wrote:
>
> > On 2014-05-16 18:20:35 +0200, Magnus Hagander wrote:
> > > On Fri, May 16, 2014 at 5:46 PM, Joshua D. Drake <jd(at)commandprompt(dot)com
> > >wrote:
> > >
> > > > At a minimum:
> > > >
> > > > Check to see if there is going to be a permission error BEFORE the base
> > > > backup begins:
> > > >
> > > > starting basebackup:
> > > > checking perms: ERROR no access to pg_hba.conf~ base backup will fail
> > >
> > >
> > > That's pretty much what it does if you enable progress meter. I realize
> > you
> > > don't necessarily want that one, but we could have a switch that still
> > > tells the server to measure the size, but not actually print the output?
> > > While it costs a bit of overhead to do that, that's certainly something
> > > that's a lot more safe than ignoring errors.
> >
> > Don't think it'll show you that error - that mode only stats() files,
> > right? So you'd need to add access() or open()s.
> >
> >
> You're right, we don't. I thought we did, but was clearly remembering wrong.
>
> I guess we could add an access() call to that codepath though. Not sure if
> that's going to cause any real overhead compared to the rest of what we're
> doing anyway?

It's not free. But I don't think it'd seriously matter in comparison.

But it doesn't protect you if the file is created during the backup -
which as you know can take a long time. For example because somebody
felt the need to increase wal_keep_segments.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_basebackup: could not get transaction log end position from server: FATAL: could not open file "./pg_hba.conf~": Permission denied
Date: 2014-05-16 17:01:48
Message-ID: 5376447C.6070903@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 05/16/2014 09:20 AM, Magnus Hagander wrote:
>
> On Fri, May 16, 2014 at 5:46 PM, Joshua D. Drake <jd(at)commandprompt(dot)com
> <mailto:jd(at)commandprompt(dot)com>> wrote:
>
> At a minimum:
>
> Check to see if there is going to be a permission error BEFORE the
> base backup begins:
>
> starting basebackup:
> checking perms: ERROR no access to pg_hba.conf~ base backup will fail
>
>
> That's pretty much what it does if you enable progress meter. I realize
> you don't necessarily want that one, but we could have a switch that
> still tells the server to measure the size, but not actually print the
> output? While it costs a bit of overhead to do that, that's certainly
> something that's a lot more safe than ignoring errors.

That seems reasonable.

JD


From: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_basebackup: could not get transaction log end position from server: FATAL: could not open file "./pg_hba.conf~": Permission denied
Date: 2014-05-16 17:11:58
Message-ID: 1400260318401-5804257.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andres Freund-3 wrote
> On 2014-05-16 18:29:25 +0200, Magnus Hagander wrote:
>> On Fri, May 16, 2014 at 6:25 PM, Andres Freund &lt;

> andres@

> &gt;wrote:
>>
>> > On 2014-05-16 18:20:35 +0200, Magnus Hagander wrote:
>> > > On Fri, May 16, 2014 at 5:46 PM, Joshua D. Drake &lt;

> jd@

> &gt; > >wrote:
>> > >
>> > > > At a minimum:
>> > > >
>> > > > Check to see if there is going to be a permission error BEFORE the
>> base
>> > > > backup begins:
>> > > >
>> > > > starting basebackup:
>> > > > checking perms: ERROR no access to pg_hba.conf~ base backup will
>> fail
>> > >
>> > >
>> > > That's pretty much what it does if you enable progress meter. I
>> realize
>> > you
>> > > don't necessarily want that one, but we could have a switch that
>> still
>> > > tells the server to measure the size, but not actually print the
>> output?
>> > > While it costs a bit of overhead to do that, that's certainly
>> something
>> > > that's a lot more safe than ignoring errors.
>> >
>> > Don't think it'll show you that error - that mode only stats() files,
>> > right? So you'd need to add access() or open()s.
>> >
>> >
>> You're right, we don't. I thought we did, but was clearly remembering
>> wrong.
>>
>> I guess we could add an access() call to that codepath though. Not sure
>> if
>> that's going to cause any real overhead compared to the rest of what
>> we're
>> doing anyway?
>
> It's not free. But I don't think it'd seriously matter in comparison.
>
> But it doesn't protect you if the file is created during the backup -
> which as you know can take a long time. For example because somebody
> felt the need to increase wal_keep_segments.
>
> Greetings,
>
> Andres Freund

Can we simply backup the non-data parts of $PGDATA first then move onto the
data-parts? For the files that we'd be dealing with it would be
sufficiently quick to just try and fail, immediately, then check for all
possible preconditions first. The main issue seems to be the case where the
2TB of data get backed-up and then a small 1k file blows away all that work.
Lets do those 1k files first.

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/pg-basebackup-could-not-get-transaction-log-end-position-from-server-FATAL-could-not-open-file-pg-hbd-tp5804225p5804257.html
Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.


From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: pg_basebackup: could not get transaction log end position from server: FATAL: could not open file "./pg_hba.conf~": Permission denied
Date: 2014-05-16 19:39:26
Message-ID: 5376696E.2040306@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 05/16/2014 08:11 PM, David G Johnston wrote:
> Can we simply backup the non-data parts of $PGDATA first then move onto the
> data-parts? For the files that we'd be dealing with it would be
> sufficiently quick to just try and fail, immediately, then check for all
> possible preconditions first. The main issue seems to be the case where the
> 2TB of data get backed-up and then a small 1k file blows away all that work.
> Lets do those 1k files first.

You'll still need to distinguish "data" and "non-data" parts somehow.
One idea would be to backup any files in the top directory first, before
recursing into the subdirectories. That would've caught the OP's case,
and probably many other typical cases where you drop something
unexpected into $PGDATA. You could still have something funny nested
deep in the data directory, but that's much less common.

- Heikki