Re: AW: [Extern] Re: promote a deferred standby without applying WALs - Mailing list pgsql-admin

From Laurenz Albe
Subject Re: AW: [Extern] Re: promote a deferred standby without applying WALs
Date
Msg-id 9720a2c9245df13906591abc4ede6cb10db32ab3.camel@cybertec.at
Whole thread Raw
In response to AW: [Extern] Re: promote a deferred standby without applying WALs  ("Zwettler Markus (OIZ)" <Markus.Zwettler@zuerich.ch>)
List pgsql-admin
On Tue, 2024-07-16 at 09:01 +0000, Zwettler Markus (OIZ) wrote:
> > On Tue, 2024-07-16 at 08:04 +0000, Zwettler Markus (OIZ) wrote:
> > > I have a standby database running 3 hours behind the primary (recovery_min_apply_delay = '3h').
> > >
> > > In case of a logical error on the primary I want to promote the standby database
> > > which still has correct data.
> > >
> > > The standby should not apply any more WAL in that case.
> > >
> > > It seems that this can only be done manually:
> > >
> > >    1. pg_ctl stop
> > >    2. rm -rf standby.signal
> > >    3. set primary_conninfo = ''
> > >    4. pg_ctl start
> > >
> > > Is there no single command on this?
> >
> > Perhaps this could be the single command:
> >
> >   psql -c "ALTER SYSTEM SET recovery_target_time = '2024-07-16 12:00:00'" -c
> > "SELECT pg_reload_conf()"
>
> setting recovery_target_time + reload would be step 0 in that case, before stop/start. correct?

No, that would be the only step.  A restart is not necessary, and PostgreSQL will
automatically promote the standby when the target time is reached (if you set
"recovery_target_action" to "promote").

Yours,
Laurenz Albe

Attachment

pgsql-admin by date:

Previous
From: "Zwettler Markus (OIZ)"
Date:
Subject: AW: [Extern] Re: promote a deferred standby without applying WALs
Next
From: Wasim Devale
Date:
Subject: Re: indexes on partitioned tables