Re: how to tell master from replica

From: bricklen <bricklen(at)gmail(dot)com>
To: Scott Ribe <scott_ribe(at)elevated-dev(dot)com>
Cc: Postgresql General <pgsql-general(at)postgresql(dot)org>
Subject: Re: how to tell master from replica
Date: 2013-09-26 00:19:18
Message-ID: CAGrpgQ_xrWZjWeuK5kzQTu3xuV-yQdCT7tUC1d0xevCQJ2JyDg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Sep 25, 2013 at 5:11 PM, bricklen <bricklen(at)gmail(dot)com> wrote:

>
> On Wed, Sep 25, 2013 at 4:53 PM, Scott Ribe <scott_ribe(at)elevated-dev(dot)com>wrote:
>
>> Assuming a master & replica set up using streaming replication, hot
>> standby, 9.3.
>>
>> I'd like to have a single script on both machines distinguish whether
>> it's running on the machine with the master or replica, and take different
>> actions accordingly.
>>
>> Is the way to do this to check for the presence of wal sender process vs
>> wal receiver process? Or is there a query that could executed against sys
>> tables to find current running config of the local postmaster?
>>
>
> Would pg_is_in_backup() do the job?
>
>
> http://www.postgresql.org/docs/9.3/static/functions-admin.html#FUNCTIONS-ADMIN-BACKUP
>
>
Sorry, meant "pg_is_in_recovery()". (Michael's response tipped me off)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Scott Ribe 2013-09-26 00:52:36 Re: how to tell master from replica
Previous Message Michael Paquier 2013-09-26 00:13:20 Re: how to tell master from replica