pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedtell master to tell it's the master - ?
4+ messages / 3 participants
[nested] [flat]
* tell master to tell it's the master - ?
@ 2023-08-18 09:07 lejeczek <peljasz@yahoo.co.uk>
0 siblings, 1 reply; 4+ messages in thread
From: lejeczek @ 2023-08-18 09:07 UTC (permalink / raw)
To: pgsql-admin@lists.postgresql.org
Hi guys.
Is it possible to configure pgSQL to announce it's being a
master and not querying it?
I was hoping for a file whose existence or content would
confirm that and would be generated/created by pqSQL itself
- am I too naive?
many thanks, L.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: tell master to tell it's the master - ?
@ 2023-08-18 09:34 Emile Amewoto <emileam@yahoo.com>
parent: lejeczek <peljasz@yahoo.co.uk>
0 siblings, 1 reply; 4+ messages in thread
From: Emile Amewoto @ 2023-08-18 09:34 UTC (permalink / raw)
To: lejeczek <peljasz@yahoo.co.uk>; +Cc: pgsql-admin@lists.postgresql.org
Hi Lejeczek,
What are you using to control your cluster?
If you are using patroni, you can use regex to grep the Leader or if you are not using any cluster manager you can do:
SELECT Count(pid))
FROM pg_stat_activity WHERE wait_event IS NOT NULL AND backend_type = ‘walsender'
The master will always have walsender process and the standby walreiver
Regards,
Emile
> On 18 Aug 2023, at 11:07, lejeczek <peljasz@yahoo.co.uk> wrote:
>
> Hi guys.
>
> Is it possible to configure pgSQL to announce it's being a master and not querying it?
> I was hoping for a file whose existence or content would confirm that and would be generated/created by pqSQL itself - am I too naive?
>
> many thanks, L.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: tell master to tell it's the master - ?
@ 2023-08-18 11:06 lejeczek <peljasz@yahoo.co.uk>
parent: Emile Amewoto <emileam@yahoo.com>
0 siblings, 1 reply; 4+ messages in thread
From: lejeczek @ 2023-08-18 11:06 UTC (permalink / raw)
To: ; +Cc: pgsql-admin@lists.postgresql.org
On 18/08/2023 11:34, Emile Amewoto wrote:
> Hi Lejeczek,
> What are you using to control your cluster?
> If you are using patroni, you can use regex to grep the
> Leader or if you are not using any cluster manager you can do:
>
> SELECT Count(pid))
> FROM pg_stat_activity WHERE wait_event IS NOT
> NULL AND backend_type = ‘walsender'
> The master will always have walsender process and the
> standby walreiver
>
> Regards,
> Emile
>
>> On 18 Aug 2023, at 11:07, lejeczek <peljasz@yahoo.co.uk>
>> wrote:
>>
>> Hi guys.
>>
>> Is it possible to configure pgSQL to announce it's being
>> a master and not querying it?
>> I was hoping for a file whose existence or content would
>> confirm that and would be generated/created by pqSQL
>> itself - am I too naive?
>>
>> many thanks, L.
>
Hi, thanks for the tip.
I'm looking at what I wrote - perhaps I was bit vague - ...
it's being a master by not querying it & via means of
config/uration instead - is what wanted to ask.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: tell master to tell it's the master - ?
@ 2023-08-18 12:36 Hotmail <crajac66@hotmail.com>
parent: lejeczek <peljasz@yahoo.co.uk>
0 siblings, 0 replies; 4+ messages in thread
From: Hotmail @ 2023-08-18 12:36 UTC (permalink / raw)
To: lejeczek <peljasz@yahoo.co.uk>; +Cc: pgsql-admin@lists.postgresql.org
Hi,
I know you don’t want to query, but you could create your own pseudo configuration file with a query and a psql \if statement in a psql script like this:
select NOT pg_is_in_recovery() AS is_primary \gset
\if :is_primary
\! touch /tmp/primary_at_’date +%Y%m%d%H%M%S’
\endif
\q
Run the above on each database in your cluster with a cron job/database scheduler job at the appropriate interval for your needs. This would provide a file in / tmp that identifies the primary database with a timestamp.
Hope this helps.
Regards,
Craig Jackson
On Aug 18, 2023 at 7:07 AM -0400, lejeczek <peljasz@yahoo.co.uk>, wrote:
>
>
> On 18/08/2023 11:34, Emile Amewoto wrote:
> > Hi Lejeczek,
> > What are you using to control your cluster?
> > If you are using patroni, you can use regex to grep the Leader or if you are not using any cluster manager you can do:
> >
> > SELECT Count(pid))
> > FROM pg_stat_activity WHERE wait_event IS NOT NULL AND backend_type = ‘walsender'
> > The master will always have walsender process and the standby walreiver
> >
> > Regards,
> > Emile
> >
> > > On 18 Aug 2023, at 11:07, lejeczek <peljasz@yahoo.co.uk> wrote:
> > >
> > > Hi guys.
> > >
> > > Is it possible to configure pgSQL to announce it's being a master and not querying it?
> > > I was hoping for a file whose existence or content would confirm that and would be generated/created by pqSQL itself - am I too naive?
> > >
> > > many thanks, L.
> >
> Hi, thanks for the tip.
> I'm looking at what I wrote - perhaps I was bit vague - ... it's being a master by not querying it & via means of config/uration instead - is what wanted to ask.
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2023-08-18 12:36 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-08-18 09:07 tell master to tell it's the master - ? lejeczek <peljasz@yahoo.co.uk>
2023-08-18 09:34 ` Emile Amewoto <emileam@yahoo.com>
2023-08-18 11:06 ` lejeczek <peljasz@yahoo.co.uk>
2023-08-18 12:36 ` Hotmail <crajac66@hotmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox