Re: How to send queries to master and failover to slave ? - Mailing list pgsql-jdbc

From Mikko Tiihonen
Subject Re: How to send queries to master and failover to slave ?
Date
Msg-id AM4PR0701MB20512F08D340B07CEFFCD13DE6220@AM4PR0701MB2051.eurprd07.prod.outlook.com
Whole thread Raw
In response to How to send queries to master and failover to slave ?  (Benoit Salotti <benoit.salotti@gmail.com>)
Responses Re: How to send queries to master and failover to slave ?
List pgsql-jdbc

Assuming that the old slave will become new master if master ever goes down then the option "master" would do what you want. Right?

But if you do take the master down for maintenance without failing over to slave then yes. A small code change could be done to add support for preferMaster.


-Mikko


From: pgsql-jdbc-owner@postgresql.org <pgsql-jdbc-owner@postgresql.org> on behalf of Benoit Salotti <benoit.salotti@gmail.com>
Sent: 28 June 2016 12:41
To: pgsql-jdbc@postgresql.org
Subject: [JDBC] How to send queries to master and failover to slave ?
 
Hi all,

I have a setup with 1 master and 1 slave (hot standy to serve read queries if necessary).
I would like the JDBC driver to talk preferrably to the master (to be sure to get the freshest data). If the master is not available I would like to send the queries to the slave.

The documentation mentions the following values for the parameter targetServerType: any, master, slave, preferSlave.
I'm surprised there is no preferMaster option which would allow me to implement easily my requirement.

Anyone already encountered the same need ?

Regards,

Benoit

pgsql-jdbc by date:

Previous
From: Benoit Salotti
Date:
Subject: How to send queries to master and failover to slave ?
Next
From: John R Pierce
Date:
Subject: Re: How to send queries to master and failover to slave ?