| From: | Tatsuo Ishii <ishii(at)postgresql(dot)org> |
|---|---|
| To: | pgpool-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | target_session_attrs |
| Date: | 2026-10-17 09:21:23 |
| Message-ID: | 20261017.182123.1397069454561325122.ishii@postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgpool-hackers |
libpq's target_session_attrs is to select backend by certain
properties to be acceptable [1]. Currently possible value for it are
"any", "read-write", "read-only", "primary", "standby" and
"prefer-standby" as of PostgreSQL 19.
Unfortunately other than "any", target_session_attrs will not work as
expected if used against Pgpool-II. The reason is, because Pgpool-II
is a proxy which manages multiple backends. IMO there's no way to
avoid the issue. So I decided to add this as a new restriction
qentry. Attached is the patches for it. For your convenience, a text
version in English is shown below. Comments are welcome.
------------------------------------------------------------
target_session_attrs
Do not set libpq's connection parameter target_session_attrs to other
than any to connect to Pgpool-II. target_session_attrs is a libpq's
feature to select PostgreSQL to connect to by specifying its kind. For
example, if target_session_attrs is set to primary, libpq will check
in_hot_standby ParameterStatus value while connecting to Pgpool-II to
make sure that it is off. Pgpool-II always returns the value of the
main server (the smallest node id server which is not in down
status). If the node 0 is the main server and it's a standby by
chance, libpq will receive in_hot_standby = on, which is not the
expected value (in_hot_standby = off). Therefore it's treated as an
error in libpq side.
What happens if target_session_attrs = read-only and the node 0 is the
main server and it's a standby? In this case libpq can connects to
Pgpool-II normally. However, even if a write query is sent, it does
not raise an error as Pgpool-II redirects the query to primary. This
may be an unexpected behavior for libpq applications.
------------------------------------------------------------
[1] https://www.postgresql.org/docs/19/libpq-connect.html#LIBPQ-CONNECT-TARGET-SESSION-ATTRS
Regards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp
| Attachment | Content-Type | Size |
|---|---|---|
| restrictions.patch | application/octet-stream | 3.9 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Emond Papegaaij | 2026-10-19 10:46:29 | Segfault when a watchdog sync changes the primary under running children |
| Previous Message | Nadav Shatz | 2026-10-14 06:08:55 | Re: Removing support for FE/BE protocol version 2 |