RE: Libpq support to connect to standby server as priority

From: "tsunakawa(dot)takay(at)fujitsu(dot)com" <tsunakawa(dot)takay(at)fujitsu(dot)com>
To: 'Greg Nancarrow' <gregn4422(at)gmail(dot)com>
Cc: 'Alvaro Herrera from 2ndQuadrant' <alvherre(at)alvh(dot)no-ip(dot)org>, 'Haribabu Kommi' <kommi(dot)haribabu(at)gmail(dot)com>, 'Robert Haas' <robertmhaas(at)gmail(dot)com>, 'Laurenz Albe' <laurenz(dot)albe(at)cybertec(dot)at>, 'Tom Lane' <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 'Dave Cramer' <pg(at)fastcrypt(dot)com>, 'Jing Wang' <jingwangian(at)gmail(dot)com>, 'PostgreSQL-development' <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: Libpq support to connect to standby server as priority
Date: 2019-12-20 00:41:21
Message-ID: OSAPR01MB50734B39D871EE8CC40D133FFE2D0@OSAPR01MB5073.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

From: Greg Nancarrow <gregn4422(at)gmail(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ranier Vilela 2019-12-20 00:42:06 Re: [PATCH] Fix expressions always false
Previous Message Vik Fearing 2019-12-20 00:30:00 Re: polymorphic table functions light