Re: Patch: Implement failover on libpq connect level.

From: "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>
To: 'Mithun Cy' <mithun(dot)cy(at)enterprisedb(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Peter van Hardenberg <pvh(at)pvh(dot)ca>, Peter Eisentraut <peter_e(at)gmx(dot)net>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Patch: Implement failover on libpq connect level.
Date: 2016-11-18 01:09:46
Message-ID: 0A3221C70F24FB45833433255569204D1F641BA6@G01JPEXMBYT05
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-jdbc

From: pgsql-hackers-owner(at)postgresql(dot)org
> [mailto:pgsql-hackers-owner(at)postgresql(dot)org] On Behalf Of Mithun Cy
> I am adding next version of the patch it have following fixes.
> Tsunakawa's comments
>
> 1. PGconn->target_server_type is now freed in freePGconn() 2. Added
> PGTARGETSERVERTYPE.
>
>
> Additional comments from others
> 3. Moved from SELECT pg_is_in_recovery() to SHOW transaction_read_only
> now should handle different kind of replication, as we recognise server
> to which writable connection can be made as primary. Very exactly like JDBC
> driver. Also documented about it.
> 4. renamed words from master to primary.

Thank you. The following items need addressing. Some of them require some more discussion to reach consensus, and I hope they will settle down soon. After checking the progress for a week or so, I'll mark the CommitFest entry as "ready for committer" or "waiting on author".

(1)
+ server. Set this to <literaL>any</literal>, if you want to connect to
+ A server is recognized as a primary/standby by observering whether it

Typo. <literaL. -> <literal>, and "observering" -> "observing".

(2)
+ {"target_server_type", "PGTARGETSERVERTYPE", NULL, NULL,
+ "Target server type", "", 6,

Looking at existing parameters, the default value is defined as a macro, and the display label is a sequence of words separated by "-". i.e.

+ {"target_server_type", "PGTARGETSERVERTYPE", DefaultTargetServerType, NULL,
+ "Target-Server-Type", "", 6,

(3)
Please avoid adding another round trip by using a GUC_REPORTed variable (ParameterStatus entry). If you want to support this libpq failover with pre-10 servers, you can switch the method of determining the primary based on the server version. But I don't think it's worth supporting older servers at the price of libpq code complexity.

(4)
Please consider supporting "standby" and "prefer_standby" like PgJDBC. They are useful without load balancing when multiple standbys are used for HA.

(5)
I haven't tracked the progress of logical replication, but will target_server_type be likely to be usable with it? How will target_server_type fit logical replication?

Regards
Takayuki Tsunakawa

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2016-11-18 01:18:45 Re: Declarative partitioning - another take
Previous Message Craig Ringer 2016-11-18 00:15:36 Re: Document how to set up TAP tests for Perl 5.8.8

Browse pgsql-jdbc by date

  From Date Subject
Next Message Craig Ringer 2016-11-18 03:08:20 Re: Patch: Implement failover on libpq connect level.
Previous Message Mithun Cy 2016-11-17 11:33:15 Re: Patch: Implement failover on libpq connect level.