Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tKKnM-0086Fn-45 for psycopg@arkaria.postgresql.org; Sun, 08 Dec 2024 17:10:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tKKnI-001wHC-QB for psycopg@arkaria.postgresql.org; Sun, 08 Dec 2024 17:10:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tKKnI-001wH0-1z for psycopg@lists.postgresql.org; Sun, 08 Dec 2024 17:10:09 +0000 Received: from fhigh-b1-smtp.messagingengine.com ([202.12.124.152]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tKKnC-001gti-MG for psycopg@postgresql.org; Sun, 08 Dec 2024 17:10:07 +0000 Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfhigh.stl.internal (Postfix) with ESMTP id DDA2225400D7; Sun, 8 Dec 2024 12:10:01 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Sun, 08 Dec 2024 12:10:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1733677801; x=1733764201; bh=EruoPBPbpPFRLj965Zpzn9fEgTvYosPSq8PZcaM5pvA=; b= IuO6y09PPXaLeAaPkYnPL0BdZnhwL0y+KHWv8StegZ4WtWbDEalkqZY7mAsnAmNR dgnrrTvo+DUG5M5eE3kmWCI5Bgawm8tQH41hUi2yckpX08WLT7GUs3qDvSexdNx9 lWkBTLP/MUDgSjJXx9nXCppXShY6dvh/s4i7yTptM5Nf2xDg4edCn/2NhCYoEsmF 48OFwLh8hQ0dcOzddIYO/pJle/Uaf+PbN7oDwz+ouQ6/bicyhAdXNM6iSehPexP3 qul7LJgdW2Wb2R+MHRchxRFz7UPxRK3EUnH9PRGKaCiP0hpDesjWlUd/BgN4ZLps dWd729dDG6FpPIfBUr0s5g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1733677801; x=1733764201; bh=E ruoPBPbpPFRLj965Zpzn9fEgTvYosPSq8PZcaM5pvA=; b=x5WggU5hFxmfGVv4Q m/vonC8KS6AEblKa54hoceLaUPxkBrKO7D+wIileY5cL8S6bni0f37S1XviKzr39 9JhE5HVCMn5svWy7DviVS7d81nlKKKg6gB2Nlc5FKXcD2FrbgBC5CJKkmp61pOIE EDIHuulDTFjH5p3xV5p4FtuoQiQTo885JHOe5a/ua+HejQUwjNH6zVp6K6JUCbvz 5BEtWNXK2j1raAY4jMALzK7MoVh8jNNhX9OXoKhtA8IuG3Vveb0TYWLea6oUNf0s ggoqqjC1sOVLnd5llBY10XR3SeqthnIviAz6PhZITXbD/PsuvmQdjaGwu3WPTHeg uS0dQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrjeefgdellecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuf fvfhfhjggtgfesthekredttddvjeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcu oegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmqeenucggtffrrghtth gvrhhnpeffleegieefgfevudehtdfhkeeutdffjeevgeffgeejvedthefgudeiteefheej heenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrug hrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmpdhnsggprhgtphhtthhopedv pdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehpihgurghohhesghdrshhkkhhurd gvughupdhrtghpthhtohepphhshigtohhpghesphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 8 Dec 2024 12:10:00 -0500 (EST) Message-ID: <5ed40ad0-5012-48fa-b5c0-61abf7713080@aklaver.com> Date: Sun, 8 Dec 2024 09:09:59 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Best Practices for Checking PostgreSQL Server Mode with Multiple Connections To: YoungUk Song , psycopg@postgresql.org References: Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 adrian.klaver@aklaver.com