Обсуждение: how to distinguish between using the server as a standby or for executing a targeted recovery in PG 11?

Поиск
Список
Период
Сортировка

how to distinguish between using the server as a standby or for executing a targeted recovery in PG 11?

От
Bharath Rupireddy
Дата:
Hi,

I'm trying to set up a postgres server with version 11 in targeted
recovery mode (for the first time after my journey started with
postgres) and I came across the explanation at [1] in PG 12 and newer
versions that we have a clear differentiation as to what is the
"standby" mode or "targeted recovery" mode. How do we differentiate
these two modes in PG 11? Can anyone please help me with it?

PS: hackers-list may not be the right place to ask, but I'm used to
seeking help from it.

[1] From the https://www.postgresql.org/docs/12/runtime-config-wal.html:

"19.5.4. Archive Recovery

This section describes the settings that apply only for the duration
of the recovery. They must be reset for any subsequent recovery you
wish to perform.

“Recovery” covers using the server as a standby or for executing a
targeted recovery. Typically, standby mode would be used to provide
high availability and/or read scalability, whereas a targeted recovery
is used to recover from data loss.

To start the server in standby mode, create a file called
standby.signal in the data directory. The server will enter recovery
and will not stop recovery when the end of archived WAL is reached,
but will keep trying to continue recovery by connecting to the sending
server as specified by the primary_conninfo setting and/or by fetching
new WAL segments using restore_command. For this mode, the parameters
from this section and Section 19.6.3 are of interest. Parameters from
Section 19.5.5 will also be applied but are typically not useful in
this mode.

To start the server in targeted recovery mode, create a file called
recovery.signal in the data directory. If both standby.signal and
recovery.signal files are created, standby mode takes precedence.
Targeted recovery mode ends when the archived WAL is fully replayed,
or when recovery_target is reached. In this mode, the parameters from
both this section and Section 19.5.5 will be used."

Regards,
Bharath Rupireddy.



Re: how to distinguish between using the server as a standby or for executing a targeted recovery in PG 11?

От
"Euler Taveira"
Дата:
On Fri, Sep 24, 2021, at 1:46 PM, Bharath Rupireddy wrote:
I'm trying to set up a postgres server with version 11 in targeted
recovery mode (for the first time after my journey started with
postgres) and I came across the explanation at [1] in PG 12 and newer
versions that we have a clear differentiation as to what is the
"standby" mode or "targeted recovery" mode. How do we differentiate
these two modes in PG 11? Can anyone please help me with it?
It seems you have to rely on parsing recovery.conf. However, someone can modify
it after starting Postgres. In this case, you have to use a debugger such as

gdb /path/to/postgres -p $(pgrep -f 'postgres: startup recovering') -quiet -batch -ex 'p StandbyMode' -ex 'quit'

Unfortunately, there is no simple way such as checking if a .signal file exists.


--
Euler Taveira

Re: how to distinguish between using the server as a standby or for executing a targeted recovery in PG 11?

От
Andrew Dunstan
Дата:
On 9/24/21 12:46 PM, Bharath Rupireddy wrote:
> Hi,
>
> I'm trying to set up a postgres server with version 11 in targeted
> recovery mode (for the first time after my journey started with
> postgres) and I came across the explanation at [1] in PG 12 and newer
> versions that we have a clear differentiation as to what is the
> "standby" mode or "targeted recovery" mode. How do we differentiate
> these two modes in PG 11? Can anyone please help me with it?
>
> PS: hackers-list may not be the right place to ask, but I'm used to
> seeking help from it.
>


see <https://www.postgresql.org/docs/11/recovery-target-settings.html>
and <https://www.postgresql.org/docs/11/standby-settings.html>


(And yes, pgsql-general would be the right forum)


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com




Re: how to distinguish between using the server as a standby or for executing a targeted recovery in PG 11?

От
Bharath Rupireddy
Дата:
On Tue, Sep 28, 2021 at 7:39 PM Andrew Dunstan <andrew@dunslane.net> wrote:
>
>
> On 9/24/21 12:46 PM, Bharath Rupireddy wrote:
> > Hi,
> >
> > I'm trying to set up a postgres server with version 11 in targeted
> > recovery mode (for the first time after my journey started with
> > postgres) and I came across the explanation at [1] in PG 12 and newer
> > versions that we have a clear differentiation as to what is the
> > "standby" mode or "targeted recovery" mode. How do we differentiate
> > these two modes in PG 11? Can anyone please help me with it?
> >
> > PS: hackers-list may not be the right place to ask, but I'm used to
> > seeking help from it.
> >
>
>
> see <https://www.postgresql.org/docs/11/recovery-target-settings.html>
> and <https://www.postgresql.org/docs/11/standby-settings.html>

Thanks! It looks like the 'standby_mode = off' in the recovery.conf
with a 'recovery_target' makes the server to be in "targeted recovery"
mode.

Regards,
Bharath Rupireddy.