Re: (replication) Detecting if server a slave, or a master in recovery - Mailing list pgsql-general

From Toby Corkindale
Subject Re: (replication) Detecting if server a slave, or a master in recovery
Date
Msg-id 4E6DB286.1040001@strategicdata.com.au
Whole thread Raw
In response to Re: (replication) Detecting if server a slave, or a master in recovery  (Simon Riggs <simon@2ndQuadrant.com>)
Responses Re: (replication) Detecting if server a slave, or a master in recovery  (Simon Riggs <simon@2ndQuadrant.com>)
List pgsql-general
On 12/09/11 17:13, Simon Riggs wrote:
> On Mon, Sep 12, 2011 at 7:54 AM, Toby Corkindale
> <toby.corkindale@strategicdata.com.au>  wrote:
>
>> What is the correct way to tell what mode a replicated Pg server is
>> currently in, via a database connection?
>>
>> I can take a guess if it's the master or a slave by using the
>> pg_current_xlog_location() and pg_last_xlog_replay_location() functions.
>>
>> However it occurs to me that a master server, which has been roughly
>> rebooted and is replaying its WAL files will probably give the same response
>> as a slave, when I call the current_xlog_location().
>>
>>
>> What is the best method for determining whether you're connected to the
>> master or slave database?
>
> SELECT pg_is_in_recovery();


If I'm on a master database, which had previously crashed and is now in
the process of recovery, won't that also return "true" there?

pgsql-general by date:

Previous
From: Simon Riggs
Date:
Subject: Re: (replication) Detecting if server a slave, or a master in recovery
Next
From: Simon Riggs
Date:
Subject: Re: (replication) Detecting if server a slave, or a master in recovery