Re: detecting binary backup in progress

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: Joe Conway <mail(at)joeconway(dot)com>, "Hackers (PostgreSQL)" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: detecting binary backup in progress
Date: 2013-05-31 19:36:32
Message-ID: 20130531193632.GG4606@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2013-05-31 22:29:45 +0300, Heikki Linnakangas wrote:
> On 31.05.2013 21:41, Joe Conway wrote:
> >On 05/31/2013 10:46 AM, Heikki Linnakangas wrote:
> >>On 31.05.2013 20:38, Joe Conway wrote:
> >>>I can check for the presence of $PGDATA/backup_label in order to
> >>>detect a backup in progress (i.e. pg_start_backup() has been run
> >>>and pg_stop_backup() has not yet been run).
> >>>
> >>>However there is a period of time after pg_start_backup() is
> >>>first executed to when it completes, during which backup_label
> >>>file does not exist yet, but the backup has essentially been
> >>>started. Is there any way to detect this state?
> >>
> >>What are you trying to accomplish? Even if you eliminate that
> >>window, it's always possible that a backup starts just after you've
> >>checked that there is no backup in progress.
> >
> >We can lay down a lockfile before checking for backup in progress, and
> >the script that starts the backup can check for the lockfile before
> >doing anything. There is still a race-window, but I want to minimize
> >it. pg_is_in_backup() mentioned nearby on this thread will help close
> >the gap.
>
> Note that pg_is_in_backup() just checks for presence of
> $PGDATA/backup_label. Also note that pg_basebackup doesn't create
> backup_label in the server. It's included in the backup that's sent to the
> client, but it's never written to disk in the server. So checking for
> backup_label manually or with pg_is_in_backup() will return false even if
> pg_basebackup is running.

Whoa. You are right, but I'd call that a bug. I don't understand why we
aren't just checking
XLogCtl->Insert.(nonExclusiveBackups||exlusiveBackup)?

I vote for changing this before we release pg_is_in_backup().

Greetings,

Andres Freund

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2013-05-31 19:45:57 Re: removing PD_ALL_VISIBLE
Previous Message Joe Conway 2013-05-31 19:35:34 Re: detecting binary backup in progress