On Tue, Aug 18, 2015 at 9:48 AM, Victor Wagner <vitus@wagner.pp.ru> wrote:
Behavoir --------
If PQconnectdb encounters connect string with multiple hosts specified, it attempts to establish connection with all these hosts simultaneously, and begins to work with server which responds first, unless loadbalancing parameter is true.
I think here you are mixing the behaviour for load balancing solution and
failover solution. It seems to me that for client-side failover solution
(which is also known as Transparent Application Failover), the connection
attempt to second server should be done after the first connection is
broken as that provide more flexibility.
If the loadbalancing parameter is true, it tries servers sequentially in the random order.
If the parameter readonly is false, after authenticating with server it executes show transaction_read_only, to find out whether current connection is to the master or to the hot standby, and connection is considered successful only if server allows read write transactions.
Although both ideas (load balancing and failover) seems worth discussing,
they are separate features and can be worked on separately. It will be