RE: Libpq support to connect to standby server as priority
tsunakawa.takay@fujitsu.com <tsunakawa.takay@fujitsu.com>
From: "tsunakawa.takay@fujitsu.com" <tsunakawa.takay@fujitsu.com>
To: 'Greg Nancarrow' <gregn4422@gmail.com>
Cc: 'Alvaro Herrera from 2ndQuadrant' <alvherre@alvh.no-ip.org>, 'Haribabu
Kommi' <kommi.haribabu@gmail.com>, 'Robert Haas' <robertmhaas@gmail.com>, 'Laurenz Albe' <laurenz.albe@cybertec.at>, 'Tom Lane' <tgl@sss.pgh.pa.us>, 'Dave Cramer' <pg@fastcrypt.com>, 'Jing Wang' <jingwangian@gmail.com>, 'PostgreSQL-development' <pgsql-hackers@postgresql.org>
Date: 2019-12-20T00:41:21Z
Lists: pgsql-hackers
From: Greg Nancarrow <gregn4422@gmail.com>
> With the permission of the original patch author, Haribabu Kommi, I’ve
> rationalized the existing 8 patches into 3 patches, merging patches
> 1-5 and 6-7, and tidying up some documentation and code comments. I
> also rebased them to the latest PG12 source code (as of October 1,
> 2019). The patch code itself is the same, except for some version
> checks that I have updated to target the features for PG13 instead of
> PG12.
> I’ve attached the updated patches.
Thank you for taking over this patch. Your arrangement has made the patches much easier to read!
I've finished reviewing, and my comments are below. Unfortunately, 0003 failed to apply (I guess only slight modification is needed to apply to HEAD.) I'd like to proceed to testing when the revised patch becomes available.
(1) 0001
+ /*
+ * Requested type is prefer-read, then record this host index
+ * and try the other before considering it later. If requested
+ * type of connection is read-only, ignore this connection.
+ */
+ if (conn->requested_session_type == SESSION_TYPE_PREFER_READ ||
+ conn->requested_session_type == SESSION_TYPE_READ_ONLY)
{
This if statement seems unnecessary, because the following part at the beginning of the CONNECTION_CHECK_TARGET case block precludes entering the if block. Cases other than "any" are handled first here.
if (conn->sversion >= 70400 &&
- conn->target_session_attrs != NULL &&
- strcmp(conn->target_session_attrs, "read-write") == 0)
+ conn->requested_session_type != SESSION_TYPE_ANY)
+ {
(2) 0002
-} TargetSessionAttrsType;
+} TargetSessionAttrsType;
One space after } is replaced with three tabs. I guess this is an unintentional change.
(3) 0002
+reject_checked_read_or_write_connection(PGconn *conn)
To follow the naming style of most internal functions in this file, I find it better to change the name to rejectCheckedReadOrWriteConnection.
(4) 0003
+reject_checked_recovery_connection(PGconn *conn)
The same as the previous one.
(5) 0003
Don't we have to describe in_recovery in both or either of high-availability.sgml and config.sgml? transaction_read_only is touched in the former.
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