Re: Patch: Implement failover on libpq connect level.
Mithun Cy <mithun.cy@enterprisedb.com>
From: Mithun Cy <mithun.cy@enterprisedb.com>
To: Aleksander Alekseev <a.alekseev@postgrespro.ru>
Cc: Victor Wagner <vitus@wagner.pp.ru>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2016-09-06T02:28:28Z
Lists: pgsql-hackers
On Mon, Sep 5, 2016 at 4:33 PM, Aleksander Alekseev <
a.alekseev@postgrespro.ru> wrote:
>After a brief examination I've found following ways to improve the patch.
Adding to above comments.
1)
+ /*
+ * consult connection options and check if RO connection is OK
+ * RO connection is OK if readonly connection is explicitely
+ * requested or if replication option is set, or just one
+ * host is specified in the connect string.
+ */
+ if ((conn->pghost==NULL || strchr(conn->pghost,',')==NULL) ||
+ ((conn->read_only && conn->read_only[0] > '0'))
+ ||(conn->replication && conn->replication[0])
+ )
+ {
Now if only one host is in connection string and it ask for read_write
connection(connect to master) I mean read_only is set 0 explicitly. With
above logic we will allow it to connect to standby?. I still think psql
connection to standby should be handled by changing the default value of
readonly to 1 (which means connect to any). Thinking further probably
replacing readonly parameter with targetServerType=any|master (with default
being any) should clear some confusions and bring consistency since same is
used in JDBC multi host connection string.
2)
@@ -1460,33 +1538,80 @@ connectDBStart(PGconn *conn)
portstr,
(int) (UNIXSOCK_PATH_BUFLEN - 1));
conn->options_valid = false;
+ free(nodes->port);
nodes->port was not allocated at this point.
--
Thanks and Regards
Mithun C Y
EnterpriseDB: http://www.enterprisedb.com
Commits
-
libpq: Add target_session_attrs parameter.
- 721f7bd3cbcc 10.0 landed
-
Remove superuser checks in pgstattuple
- fd321a1dfd64 10.0 cited
-
Fix unwanted flushing of libpq's input buffer when socket EOF is seen.
- c405918858c0 9.6.0 cited