public inbox for [email protected]  
help / color / mirror / Atom feed
From: YoungUk Song <[email protected]>
To: Adrian Klaver <[email protected]>
To: [email protected]
Subject: Re: Best Practices for Checking PostgreSQL Server Mode with Multiple Connections
Date: Mon, 9 Dec 2024 23:04:51 +0900
Message-ID: <CAK9ZnjPFsPTd20HHjX8NhpiS9zTJTAde1p30BKx85BqSiM-MgQ@mail.gmail.com> (raw)
In-Reply-To: <CAK9ZnjPvnXgZa28gpXWw0A2wkUBJnmm5dtk3sYJKkm9UgnND0Q@mail.gmail.com>
References: <CAK9ZnjNECXcXshq6OVzx8ryf0i7KNrp9TErhNkL0ga0c=K-GFA@mail.gmail.com>
	<[email protected]>
	<CAK9ZnjPvnXgZa28gpXWw0A2wkUBJnmm5dtk3sYJKkm9UgnND0Q@mail.gmail.com>

Thank you for your response!

I apologize for the confusion in my earlier message.

I need to check whether more than 500 different database servers (not just
one) are operating in read-only or read-write mode using Psycopg.

Are there any best practices for efficiently handling this task across such
a large number of servers?


Additionally, I’m considering using the target_session_attrs parameter to
solve this problem.

However, I’m unsure how to handle connection errors effectively in this
context.

Specifically, I’d like to differentiate between connection failures and
situations where the server is not in standby mode.

Can this be achieved using Psycopg's error-handling features, as described
here: https://www.psycopg.org/psycopg3/docs/api/errors.html?


Thanks!

2024년 12월 9일 (월) 오전 9:19, YoungUk Song <[email protected]>님이 작성:

> Thanks for your reply!
>
> Actually, I made a mistake in my previous message. I need to check whether
> more than 500 different database servers (not just one) are in read-only or
> read-write mode using psycopg. I’m wondering if there are any best
> practices for checking all of them.
>
> Also, I’m not sure, but can the target_session_attrs parameter be used in
> this situation?
>
> Thanks!
>
> 2024년 12월 9일 (월) 오전 2:10, Adrian Klaver <[email protected]>님이 작성:
>
>> On 12/8/24 04:45, YoungUk Song wrote:
>> > Hi Team,
>> >
>> > I’m currently implementing a solution to establish more than 500
>> > database connections to a single server to verify whether the
>> PostgreSQL
>> > server is in read-only or read-write mode.
>> The server as whole is either in recovery or it is not, that takes one
>> connection to determine. What are the remaining 499 connections for?
>>
>> >
>> > My current approach is to create individual database connections and
>> > execute the |pg_is_in_recovery()| function for each connection to
>> > determine the mode.
>> >
>> > I’m curious if there are any best practices or more efficient methods
>> to
>> > achieve this.
>> >
>> > Additionally, I’m not very familiar with Psycopg, so I would greatly
>> > appreciate any advice or suggestions on areas that might need
>> improvement.
>> >
>> > Looking forward to your insights!
>> >
>>
>> --
>> Adrian Klaver
>> [email protected]
>>
>>


view thread (5+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Best Practices for Checking PostgreSQL Server Mode with Multiple Connections
  In-Reply-To: <CAK9ZnjPFsPTd20HHjX8NhpiS9zTJTAde1p30BKx85BqSiM-MgQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox