Promoting a standby during base backup (was Re: Switching timeline over streaming replication) - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Promoting a standby during base backup (was Re: Switching timeline over streaming replication)
Date
Msg-id 506D41FA.4020003@vmware.com
Whole thread Raw
In response to Re: Switching timeline over streaming replication  (Amit Kapila <amit.kapila@huawei.com>)
Responses Re: Promoting a standby during base backup (was Re: Switching timeline over streaming replication)  (Fujii Masao <masao.fujii@gmail.com>)
List pgsql-hackers
On 03.10.2012 18:15, Amit Kapila wrote:
> On Tuesday, October 02, 2012 4:21 PM Heikki Linnakangas wrote:
>> Hmm, should a base backup be aborted when the standby is promoted? Does
>> the promotion render the backup corrupt?
>
> I think currently it does so. Pls refer
> 1.
> do_pg_stop_backup(char *labelfile, bool waitforarchive)
> {
> ..
> if (strcmp(backupfrom, "standby") == 0&&  !backup_started_in_recovery)
>                  ereport(ERROR,
>
> (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
>                                   errmsg("the standby was promoted during
> online backup"),
>                                   errhint("This means that the backup being
> taken is corrupt "
>                                                   "and should not be used. "
>                                                   "Try taking another online
> backup.")));
> ..
>
> }

Okay. I think that check in do_pg_stop_backup() actually already ensures 
that you don't end up with a corrupt backup, even if the standby is 
promoted while a backup is being taken. Admittedly it would be nicer to 
abort it immediately rather than error out at the end.

But I wonder why promoting a standby renders the backup invalid in the 
first place? Fujii, Simon, can you explain that?

- Heikki



pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Re: [WIP] Performance Improvement by reducing WAL for Update Operation
Next
From: Amit kapila
Date:
Subject: Re: [BUGS] BUG #7534: walreceiver takes long time to detect n/w breakdown