From: | Andrew Jackson <andrewjackson947(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Add Option To Check All Addresses For Matching target_session_attr |
Date: | 2024-11-20 15:51:12 |
Message-ID: | CAKK5BkESSc69sp2TiTWHvvOHCUey0rDWXSrR9pinyRqyfamUYg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
I was attempting to set up a high availability system using DNS and
target_session_attrs. I was using a DNS setup similar to below and was
trying to use the connection strings `psql postgresql://
user(at)pg(dot)database(dot)com/db_name?target_session=read-write` to have clients
dynamically connect to the primary or `psql postgresql://
user(at)pg(dot)database(dot)com/db_name?target_session=read-only` to have clients
connect to a read replica.
The problem that I found with this setup is that if libpq is unable to get
a matching target_session_attr on the first connection attempt it does not
consider any further addresses for the given host. This patch is designed
to provide an option that allows libpq to look at additional addresses for
a given host if the target_session_attr check fails for previous addresses.
Would appreciate any feedback on the applicability/relevancy of the goal
here or the implementation.
Example DNS setup
________________________________
Name | Type | Record
______________|______|___________
pg.database.com | A | ip_address_1
pg.database.com | A | ip_address_2
pg.database.com | A | ip_address_3
pg.database.com | A | ip_address_4
Attachment | Content-Type | Size |
---|---|---|
postgres.patch | text/x-patch | 2.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Sabino Mullane | 2024-11-20 15:56:11 | Re: sunsetting md5 password support |
Previous Message | Greg Sabino Mullane | 2024-11-20 15:50:36 | Re: Proposals for EXPLAIN: rename ANALYZE to EXECUTE and extend VERBOSE |