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 1tKGfc-007lsg-GJ for psycopg@arkaria.postgresql.org; Sun, 08 Dec 2024 12:45:56 +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 1tKGfY-001KsP-0E for psycopg@arkaria.postgresql.org; Sun, 08 Dec 2024 12:45:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tKGfX-001KsB-KO for psycopg@lists.postgresql.org; Sun, 08 Dec 2024 12:45:53 +0000 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tKGfT-001fWL-Un for psycopg@postgresql.org; Sun, 08 Dec 2024 12:45:50 +0000 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-5cf6f367f97so5049843a12.0 for ; Sun, 08 Dec 2024 04:45:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=g-skku-edu.20230601.gappssmtp.com; s=20230601; t=1733661945; x=1734266745; darn=postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=yGrXrhKRpxPbv+vEMF37su+6dXHGv0YxPm1HYVPkMPk=; b=nBSAdW09d344tA4yo/PqHRHMx+ybNvuvmaTzolbY7j1FlfKAU20laBCyQKXiNfRmPW X4qa48Hopg2bUaTVLXQJIPkIzDzeSC/+lsBSTM/FOn/wSaS9Zeii9x+pT46EEFOUeded ++yc4pt/uLh95LeWyqCoy20f0HiDQK3I4p0ruHhuMoU06kgDfJGuSuOg0WwGDPv7sqdB nKUuFg7CfDnFWtKA8cxkTUOPAohxhgtLOysSHsqim8G+tBgnj/DpTM0o0w51PI5prPRO zj/8JPd+bhvg+5lWwOa00zxGreoV6MIJek5EcVDFc/F1jm0LQMbMlayhfU+OZMzWOlf6 +8Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733661945; x=1734266745; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=yGrXrhKRpxPbv+vEMF37su+6dXHGv0YxPm1HYVPkMPk=; b=D0XGJU5XVUKIL5XAXoAY22vMkDX4WEGdVwYb/GfTlGdRAR/SmOEMpUTM/jPiO5ISYE svFzWKn+TlKPfPdTSfIPyCN1lHvyROJzx0LjaK20vE900H8A7ytj0Bc7e/A7i9Q29Ohz xpkGITES5+C7/SzUPdsT1pK/pxpPtEvrZ7THPtXfh6UPVd636lRXzHDFSzRUTZxj9i1N z5DuXx+BuHXGXR4sANKnjylGCkVls7ZEjdAHiNt4R4RQ+4L9PNGaEwr2QniiByK967q1 HnZyT55BVpROAbZjhEUWeyG+mZs+dXjnBIRwdwwDhH+pzXxNf5rRF2HToAoTQ5kYNN4w U0ZA== X-Gm-Message-State: AOJu0Yx30+6Pz1gOQGIbmXDi69LvKvyKHD4NhIisqnCAQFbPdL2kMVYY jhxIpzb2isM/KY64223YwBAIitPRSkHNitnajEGJKT8kw/Cih5Zoiefm4KVeZnhe4E9sIfr2OhM L6g0iK4HkCqj5ptdBrxtwX2LR86owjX0PajbVrc+iCgXovSR5xpu8jw== X-Gm-Gg: ASbGncuX3NPuD8kpL/cx/zOtExctG1zTsbVrddymOo/TBiNW5kT5RLReZrHSYli0Wse yjhcAuJx3PEMNNorO6odhjW3OAlutThMu+g== X-Google-Smtp-Source: AGHT+IF8qjYb0oeEzIxbk5Cv4HGDyinwLI1c5c7TlhZjaOz2ih9wwj017+CIeK246fbCfORJY25X2n6AXmpDuldIOyk= X-Received: by 2002:a05:6402:320d:b0:5d2:fa65:c5e2 with SMTP id 4fb4d7f45d1cf-5d3be75a9d7mr11312586a12.22.1733661945100; Sun, 08 Dec 2024 04:45:45 -0800 (PST) MIME-Version: 1.0 From: YoungUk Song Date: Sun, 8 Dec 2024 21:45:34 +0900 Message-ID: Subject: Best Practices for Checking PostgreSQL Server Mode with Multiple Connections To: psycopg@postgresql.org Content-Type: multipart/alternative; boundary="0000000000006613860628c1a0b7" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000006613860628c1a0b7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Team, I=E2=80=99m currently implementing a solution to establish more than 500 da= tabase connections to a single server to verify whether the PostgreSQL server is in read-only or read-write mode. 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=E2=80=99m curious if there are any best practices or more efficient metho= ds to achieve this. Additionally, I=E2=80=99m not very familiar with Psycopg, so I would greatl= y appreciate any advice or suggestions on areas that might need improvement. Looking forward to your insights! --0000000000006613860628c1a0b7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Hi Team,

I=E2=80=99m currently implementing a sol= ution 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.

My current approach is to create individual database connections and e= xecute the pg_is_in_recovery() function for each connection to= determine the mode.

I=E2=80=99m curious if there are any best practi= ces or more efficient methods to achieve this.

Additionally, I=E2=80= =99m not very familiar with Psycopg, so I would greatly appreciate any advi= ce or suggestions on areas that might need improvement.

Looking forwa= rd to your insights!

--0000000000006613860628c1a0b7--