Re: Terminating pg_basebackup background streamer

Lists: pgsql-hackers
From: Magnus Hagander <magnus(at)hagander(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Terminating pg_basebackup background streamer
Date: 2014-02-09 12:17:48
Message-ID: CABUevEzp2PwMTP7K5OVZsPOKrtZW3+yVL=8D=p8DgJ3Kd2Wqeg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

If an error occurs in the foreground (backup) process of pg_basebackup, and
we exit in a controlled way, the background process (streaming xlog
process) would stay around and keep streaming.

This can happen for example if disk space runs out and there is very low
activity on the server. (If there is activity on the server, the background
streamer will also run out of disk space and exit)

Attached patch kills it off in disconnect_and_exit(), which seems like the
right thing to do to me.

Any objections to applying and backpatching that for the upcoming minor
releases?

Should we perhaps also consider adding a sigterm handler to pg_basebackup,
so if you send it a SIGTERM it kills off the background process as well?

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

Attachment Content-Type Size
basebackup_kill.patch text/x-patch 2.1 KB

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Terminating pg_basebackup background streamer
Date: 2014-02-10 18:29:20
Message-ID: 52F91A80.2010307@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 02/09/2014 02:17 PM, Magnus Hagander wrote:
> If an error occurs in the foreground (backup) process of pg_basebackup, and
> we exit in a controlled way, the background process (streaming xlog
> process) would stay around and keep streaming.
>
> This can happen for example if disk space runs out and there is very low
> activity on the server. (If there is activity on the server, the background
> streamer will also run out of disk space and exit)
>
> Attached patch kills it off in disconnect_and_exit(), which seems like the
> right thing to do to me.
>
> Any objections to applying and backpatching that for the upcoming minor
> releases?

Do you get a different error message with this patch than before? Is the
new one better than the old one?

- Heikki


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Terminating pg_basebackup background streamer
Date: 2014-02-10 18:39:23
Message-ID: CABUevEyb_-pH2wz7Xd+ZPvYqbf3xDhtUX4BifutVeiCMovpNzg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Feb 10, 2014 at 7:29 PM, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com
> wrote:

> On 02/09/2014 02:17 PM, Magnus Hagander wrote:
>
>> If an error occurs in the foreground (backup) process of pg_basebackup,
>> and
>> we exit in a controlled way, the background process (streaming xlog
>> process) would stay around and keep streaming.
>>
>> This can happen for example if disk space runs out and there is very low
>> activity on the server. (If there is activity on the server, the
>> background
>> streamer will also run out of disk space and exit)
>>
>> Attached patch kills it off in disconnect_and_exit(), which seems like the
>> right thing to do to me.
>>
>> Any objections to applying and backpatching that for the upcoming minor
>> releases?
>>
>
> Do you get a different error message with this patch than before? Is the
> new one better than the old one?

Previously you got double error messages - one from the foreground, and a
second one from the background sometime in the future (whenever it
eventually failed, and for whatever reason - so if it was out of disk
space, it would complain about that once it got enough xlog for it to
happen).

With the patch you just get the error message from the first process. The
background process doesn't give an error on SIGTERM, it just exists.

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


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Terminating pg_basebackup background streamer
Date: 2014-02-12 17:47:09
Message-ID: CABUevExwwnZEfzd6QVRndOAw5dufbsX_G6HEhZp9Lpb+2=nzeA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Feb 10, 2014 at 7:39 PM, Magnus Hagander <magnus(at)hagander(dot)net>wrote:

> On Mon, Feb 10, 2014 at 7:29 PM, Heikki Linnakangas <
> hlinnakangas(at)vmware(dot)com> wrote:
>
>> On 02/09/2014 02:17 PM, Magnus Hagander wrote:
>>
>>> If an error occurs in the foreground (backup) process of pg_basebackup,
>>> and
>>> we exit in a controlled way, the background process (streaming xlog
>>> process) would stay around and keep streaming.
>>>
>>> This can happen for example if disk space runs out and there is very low
>>> activity on the server. (If there is activity on the server, the
>>> background
>>> streamer will also run out of disk space and exit)
>>>
>>> Attached patch kills it off in disconnect_and_exit(), which seems like
>>> the
>>> right thing to do to me.
>>>
>>> Any objections to applying and backpatching that for the upcoming minor
>>> releases?
>>>
>>
>> Do you get a different error message with this patch than before? Is the
>> new one better than the old one?
>
>
> Previously you got double error messages - one from the foreground, and a
> second one from the background sometime in the future (whenever it
> eventually failed, and for whatever reason - so if it was out of disk
> space, it would complain about that once it got enough xlog for it to
> happen).
>
> With the patch you just get the error message from the first process. The
> background process doesn't give an error on SIGTERM, it just exists.
>
>
>
Since there were no other objections, I've applied this patch.

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


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Magnus Hagander <magnus(at)hagander(dot)net>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Terminating pg_basebackup background streamer
Date: 2014-02-12 21:28:46
Message-ID: 52FBE78E.30802@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2/12/14, 12:47 PM, Magnus Hagander wrote:
> Since there were no other objections, I've applied this patch.

I'm getting a compiler warning:

pg_basebackup.c:105:3: error: implicit declaration of function 'kill'
[-Werror=implicit-function-declaration]


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Terminating pg_basebackup background streamer
Date: 2014-02-12 21:34:47
Message-ID: CABUevEz6eFdTCnFaO+Wpa558=eksw_OMpVbqKT6_NjQHS4mLRA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Feb 12, 2014 at 10:28 PM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:

> On 2/12/14, 12:47 PM, Magnus Hagander wrote:
> > Since there were no other objections, I've applied this patch.
>
> I'm getting a compiler warning:
>
> pg_basebackup.c:105:3: error: implicit declaration of function 'kill'
> [-Werror=implicit-function-declaration]
>

What platform is that? And do you know which header the declaration
actually lives in? I don't see it here...

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


From: Andres Freund <andres(at)anarazel(dot)de>
To: Magnus Hagander <magnus(at)hagander(dot)net>,Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Terminating pg_basebackup background streamer
Date: 2014-02-12 21:52:37
Message-ID: 04d83c16-7ef2-4d41-b43c-a6a45924435d@email.android.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On February 12, 2014 10:34:47 PM CET, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
>On Wed, Feb 12, 2014 at 10:28 PM, Peter Eisentraut <peter_e(at)gmx(dot)net>
>wrote:
>
>> On 2/12/14, 12:47 PM, Magnus Hagander wrote:
>> > Since there were no other objections, I've applied this patch.
>>
>> I'm getting a compiler warning:
>>
>> pg_basebackup.c:105:3: error: implicit declaration of function 'kill'
>> [-Werror=implicit-function-declaration]
>>
>
>What platform is that? And do you know which header the declaration
>actually lives in? I don't see it here...

Should be in the signal.h you added a bit later according to posix.

Andres

---
Please excuse brevity and formatting - I am writing this on my mobile phone.


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Terminating pg_basebackup background streamer
Date: 2014-02-12 21:53:31
Message-ID: 52FBED5B.8090301@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2/12/14, 4:34 PM, Magnus Hagander wrote:
> On Wed, Feb 12, 2014 at 10:28 PM, Peter Eisentraut <peter_e(at)gmx(dot)net
> <mailto:peter_e(at)gmx(dot)net>> wrote:
>
> On 2/12/14, 12:47 PM, Magnus Hagander wrote:
> > Since there were no other objections, I've applied this patch.
>
> I'm getting a compiler warning:
>
> pg_basebackup.c:105:3: error: implicit declaration of function 'kill'
> [-Werror=implicit-function-declaration]
>
>
> What platform is that? And do you know which header the declaration
> actually lives in? I don't see it here...

OS X, <signal.h> according to man page


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Terminating pg_basebackup background streamer
Date: 2014-02-13 11:25:01
Message-ID: CABUevEwed=rsedMYPqMsjhZgfrv0ER7ZPJBduJj8zNYxOzTopA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Feb 12, 2014 at 10:53 PM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:

> On 2/12/14, 4:34 PM, Magnus Hagander wrote:
> > On Wed, Feb 12, 2014 at 10:28 PM, Peter Eisentraut <peter_e(at)gmx(dot)net
> > <mailto:peter_e(at)gmx(dot)net>> wrote:
> >
> > On 2/12/14, 12:47 PM, Magnus Hagander wrote:
> > > Since there were no other objections, I've applied this patch.
> >
> > I'm getting a compiler warning:
> >
> > pg_basebackup.c:105:3: error: implicit declaration of function 'kill'
> > [-Werror=implicit-function-declaration]
> >
> >
> > What platform is that? And do you know which header the declaration
> > actually lives in? I don't see it here...
>
> OS X, <signal.h> according to man page
>

Are you sure you made that test after my fixup patch (the one suggested by
Andres)? Because that one was at least supposed to add signal.h...

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


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Terminating pg_basebackup background streamer
Date: 2014-02-13 14:22:41
Message-ID: 52FCD531.4060003@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2/13/14, 6:25 AM, Magnus Hagander wrote:
> Are you sure you made that test after my fixup patch (the one suggested
> by Andres)? Because that one was at least supposed to add signal.h...

works now