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.96) (envelope-from ) id 1wMuIk-000R10-2j for pgsql-hackers@arkaria.postgresql.org; Tue, 12 May 2026 21:06:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wMuIh-005wBR-0b for pgsql-hackers@arkaria.postgresql.org; Tue, 12 May 2026 21:05:59 +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.96) (envelope-from ) id 1wMuIg-005wBJ-2j for pgsql-hackers@lists.postgresql.org; Tue, 12 May 2026 21:05:59 +0000 Received: from mail-yw1-x1131.google.com ([2607:f8b0:4864:20::1131]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wMuIe-00000000GJo-2K1D for pgsql-hackers@postgresql.org; Tue, 12 May 2026 21:05:58 +0000 Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-7c52e49d978so16211727b3.2 for ; Tue, 12 May 2026 14:05:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1778619956; cv=none; d=google.com; s=arc-20240605; b=CFqHQD1qwJQtm/w15PPyWgSolYzOmaqaKlmHzN50ldLZ+SJ+DtbFnjNSZntydeizT4 KKYabQNhhZjTZBDWK9EDxt4Lq8F+zIeIIn8UPaBQ/AFR+YiNO1TcE3BivOvEb4aSBSxb BzEtt8WhN6hOTf/ktUflhL+enDDfonjDNM88MaOU2DGDdWolBiCtwPY6QmbO6uOUmAGp wPBFsfcp3evLf4DTOUYrm6wG90MzlZwKJA3SEj93YRxdDrpgBc1/+/EU8yZp0H/6w2Vx pXqrGYDWy0iFKWEyRULyVNSbqB5swPkQaLG0YhfCJrDWDAxsW9seN0jM5jBsOz4jAjFI SBkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=qMcv8+NbJvlr1uO7An+xZA4RpuMYRCaAiqhhfvGiNlY=; fh=5scN7x3aihRo88zS8LqwWHr4c0yhTYB2DBRjTUAk+C4=; b=F8aAXtpyQ5CGOJddbCwmwEMpL+J4y1qj+2uTqQ6zYHbSQxa9q2Y2vIzF26TtesCnmX IEihYYlYknqKGqKXBIY6QdVUui+gkTzTvghKvQezrJQOrbvwWKYhnmr/0CsbsrA6EgZ0 BIemo2ex0u/96lqRFIF1YLdjYO9GGGxsiaUiypnXGCQe0d+HU3HC+XuxCjWwAOSaRrfu Pexo+RGvwhuYrXmBCQ5Oz4jqVWIO1Jdduf82S15trAi/lco6Hn+iZKL16vYB3DO9Jtqa gjUCUUHuLmsXCVqs/YUxjoqBxfMp7t7BzkfHafSoYWfjVlSzBrGryHZ8hL4h5dSNByRR e8jQ==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=percona.com; s=google; t=1778619956; x=1779224756; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=qMcv8+NbJvlr1uO7An+xZA4RpuMYRCaAiqhhfvGiNlY=; b=F+TwdYNMsHvF+HzozK4wcO1WSPmdoiVYdjMPnVm3LEQ5QlfE49pjVBxq1J0FicBESm GqqlyeMgt2AVFgsy2v/Wrx/PpHOrdvFAPCo+XqXOWvz6QkKru1s+LW/zXapIT/sd2H1D 5c7GhpubAiW3KXiSB8ArjQw0oksBgNssEjaXg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778619956; x=1779224756; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qMcv8+NbJvlr1uO7An+xZA4RpuMYRCaAiqhhfvGiNlY=; b=fHbEko1PdtFuvl/LdTE3emf47tKY02vcTsNPL1DguiHFDRrYeRiNq4XU7rDBokQklj eOZ4ygZ9G80ZCYbHtw4MYjM3uhx3owAX9NBaCZZBQDezLSxhv+tgmPIPzzF4/Hbjm72w BKSnpBMkAbWmM/egwcnP8TxH/dFKP4lYbpC6olFNvpWZkoHRNKS3Rg8r5d5zwddJ4Hew teFM2gSOSlTF05zTy+ApGujUsCkGKe1B2bs1ZZec+4IDE9oVmZBKfucGNUnq3upatwPf p4MKkmQR41hWezJ1kUtuevCmVYc40wQPsWaMdHygxy9tzD7odyjLYhayKs5Ct3jd6Zqq b9bg== X-Forwarded-Encrypted: i=1; AFNElJ+LAE71P9+FHta2Y+HUBoIz4CHXQT0dogH1CLM+dc66DMQOWxWfYKCpTl0pQdvT9lZqBtGDokW0ZRKAGio6@postgresql.org X-Gm-Message-State: AOJu0YwSE6czgy8SHUYCpAjguCvrFR4GKaavwfhgjCL6NftIgbwxy8L0 LMajHAgNIAwG+77hqN2C27sshy/ycKRDtRf9YG9rr3I5wcNlW7kZoh/epIxJwyt9sD93SS6xyvz 4bT18Sc9k6Iro86XirbDXAsrNEg0fHT0H2rlGltcK8fkW1b8VIm1i1U8T9avmiwVIP1IvlEryTz C/ZjqZenkDsChxB5UdE1R0NHBhBi75UWyOExeoDbkEftv0fg3L6XScBRO6MAE60s2L3Ei/xplRa wejPaCz1jIdlQ4NiNmRCvfEDLMQ6nSMCWyP9Wj7rGoH4x2cMV4= X-Gm-Gg: Acq92OEiZU4N5RvNTw3lwLvz9rQFHMum72IZaPT8q1DxcFJt5eMr3U00Vwzh/ziyjHC 0BhIGpVyW+wcwoaNdZOXSpXAMaPBjPWM2u+KdyWy/MHEkKG0pGh9HSNiPArUJoZTW+8Tn919Hjd qfVOtpseyX+UHLnzrLbBFpgqAEvaNnlwEM8w3hc88DpFdieRKcTj4BEsLyHEftGcqu2hN1ZoG8U wKDs+lLXKbEMS0pMoMaeXzn3uOpVOPFVBfmxs0l+5X14Jof3YK83DmKbWkElioy0KMHOkYfvsyK iF23WSURLSVGjj6lyaIrRI5LdguDf3w0UZdGkgZ7/P88tioxgYAa/lJ4B4lKrO0M6vTe X-Received: by 2002:a05:690c:c6ce:10b0:7b7:5f48:d9ae with SMTP id 00721157ae682-7c6ab6e744fmr4106687b3.24.1778619955896; Tue, 12 May 2026 14:05:55 -0700 (PDT) MIME-Version: 1.0 References: <7386.1565707387@sss.pgh.pa.us> <20190814180143.62533ohqlaqcl7so@alap3.anarazel.de> <8398C22D-429A-4980-9028-4F941F2B7483@yandex-team.ru> In-Reply-To: <8398C22D-429A-4980-9028-4F941F2B7483@yandex-team.ru> From: Zsolt Parragi Date: Tue, 12 May 2026 22:05:45 +0100 X-Gm-Features: AVHnY4JeZmEGFG4CWwn2SjdTeyQE69qjoaXJJNnDSoEWRPhWXi6CSfu29JYFe40 Message-ID: Subject: Re: Feature: Use DNS SRV records for connecting To: Andrey Borodin Cc: Andres Freund , Tom Lane , Feike Steenbergen , PostgreSQL mailing lists Content-Type: text/plain; charset="UTF-8" X-CLOUD-SEC-AV-Sent: true X-CLOUD-SEC-AV-Info: percona,google_mail,monitor X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello! Shouldn't srvhost be freed in freePGconn? + /* + * If srvhost is set, validate mutual exclusivity with host/hostaddr and + * then resolve _postgresql._tcp. SRV records, populating + * conn->pghost and conn->pgport from the sorted results. This must + * happen before the host-array allocation below. + */ + if (conn->srvhost != NULL && conn->srvhost[0] != '\0') Shouldn't this also cover port? The current behavior with it seems inconsistent. > The resolved host list is sorted per RFC 2782 and injected into the > existing multi-host machinery before connhost[] is built, so > target_session_attrs, load_balance_hosts, and failover work on the > expanded list without any changes to PQconnectPoll. Doesn't RFC 2782 specifies a weighted random selection? The current code seems to be deterministically sorted by weight. RFC also says that weight=0 should be specially handled, it provides a detailed algorithm about the random selection method.