RE: Libpq support to connect to standby server as priority
Tsunakawa, Takayuki <tsunakawa.takay@jp.fujitsu.com>
From: "Tsunakawa, Takayuki" <tsunakawa.takay@jp.fujitsu.com>
To: 'Haribabu Kommi' <kommi.haribabu@gmail.com>
Cc: Laurenz Albe <laurenz.albe@cybertec.at>, Tom Lane <tgl@sss.pgh.pa.us>, Dave Cramer <pg@fastcrypt.com>, Robert Haas <robertmhaas@gmail.com>, "Jing
Wang" <jingwangian@gmail.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2019-01-18T06:20:56Z
Lists: pgsql-hackers
From: Haribabu Kommi [mailto:kommi.haribabu@gmail.com] > IMO, if we try to use only pg_is_in_recovery() only to decide to connect, > we may not > support all the target_session_attrs that are possible. how about using > both to decide? I favor adding a new parameter like target_server_type whose purpose is to select the server role. That aligns better with the PgJDBC's naming, which conveys consistency to PostgreSQL users. Again, the original desire should have been to connect to a standby to eliminate the burdon on the primary, where the primary may be read-only by default and only a limited group of users are allowed to write to the database. I don't know what kind of realistic use cases there are that request read-only session in the logical replication configuration. I think we can just leave target_session_attrs as what it is now in PostgreSQL 11, for compatibility and possibly future new use cases. > Master/read-write -- recovery = false and default_transaction_read_only > = false > Standby/read-only -- recovery = true > prefer-standby/prefer-read -- recovery = true or > default_transaction_read_only = true > any -- Nothing to be verified > > > I feel above verifications can cover for both physical and logical > replication. As for prefer-standby/prefer-read, if host parameter specifies host1,host2 in this order, and host1 is the primary with default_transaction_read_only=true, does the app get a connection to host1? I want to connect to host2 (standby) only if host1 is down. Regards Takayuki Tsunakawa
Commits
-
Make test_target_session_attrs more robust against connection failure.
- 3769e11a3183 14.0 landed
-
Extend the abilities of libpq's target_session_attrs parameter.
- ee28cacf619f 14.0 landed
-
Mark default_transaction_read_only as GUC_REPORT.
- d16f8c8e416d 14.0 landed
-
Introduce a new GUC_REPORT setting "in_hot_standby".
- bf8a662c9afa 14.0 landed
-
Avoid spamming the client with multiple ParameterStatus messages.
- 2432b1a04087 14.0 landed
-
Avoid harmless Valgrind no-buffer-pin errors.
- a766d6ca22ac 14.0 cited
-
Restructure libpq code to remove some duplicity
- b438e7e7a1c5 13.0 landed
-
libpq: Add target_session_attrs parameter.
- 721f7bd3cbcc 10.0 cited